EnVisageOnline/Main/Source/EnVisage/Models/UDFModel.cs

98 lines
3.1 KiB
C#

using EnVisage.Code;
using EnVisage.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EnVisage.Models
{
public class UDFModel:IBaseModel<UserDefinedField>
{
public Guid Id { get; set; }
[Required]
[Display(Name = "Area")]
public int DomainId { get; set; }
public Guid CreatorId { get; set; }
public Guid ModifiedById { get; set; }
[Required]
[Display(Name = "Field Type (TextBox, List,...)")]
public int Type { get; set; }
[Required]
[Display(Name = "Enabled")]
public bool Status { get; set; }
[Required]
[Display(Name = "Required Field")]
public bool Required { get; set; }
[Required]
public string Name { get; set; }
public string Description { get; set; }
[Required]
public string Label { get; set; }
public int SortOrder { get; set; }
public DateTime LastUpdate { get; set; }
[Display(Name = "Default Value")]
public string DefaultValue { get; set; }
public List<UDFValueModel> Values { get; set; }
public UDFValueModel Value { get; set; }
public string Area { get { return Utils.GetEnumDisplay(typeof(UserDefinedFieldDomain), DomainId); } }
public void CopyTo(UserDefinedField obj)
{
obj.DomainId = this.DomainId;
obj.CreatorId = this.CreatorId;
obj.DefaultValue = this.DefaultValue;
obj.Description = this.Description;
obj.Label = this.Label;
obj.Name = this.Name;
obj.Type = this.Type;
obj.SortOrder = this.SortOrder;
obj.Status = this.Status;
obj.Required = this.Required;
obj.ModifiedById = this.ModifiedById;
obj.LastUpdate = this.LastUpdate;
}
}
public class UDFValueCollection
{
public Guid Id { get; set; }
public UDFValueModel Values { get; set; }
public int Type { get; set; }
}
public class UDFValueModel
{
public Guid Id { get; set; }
public Guid ParentId { get; set; }
public Guid CreatorId { get; set; }
public Guid UserDefinedFieldId { get; set; }
public string Label { get; set; }
public string Value { get; set; }
public string DefaultValue { get; set; }
public bool Required { get; set; }
public int Area { get; set; }
public UDFValueModel Copy()
{
return new UDFValueModel()
{
Area = this.Area,
CreatorId = this.CreatorId,
DefaultValue = this.DefaultValue,
Id = Guid.Empty,
Label = this.Label,
ParentId = Guid.Empty,
Required = this.Required,
UserDefinedFieldId = this.UserDefinedFieldId,
Value = this.Value
};
}
}
}