126 lines
2.9 KiB
C#
126 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
public class CompanyModel : IBaseModel<Company>
|
|
{
|
|
public CompanyModel()
|
|
{
|
|
Watchers = new List<Guid>();
|
|
Contributors = new List<Guid>();
|
|
}
|
|
|
|
public Guid Id { get; set; }
|
|
[Required]
|
|
[MaxLength(100)]
|
|
public string Name { get; set; }
|
|
[Display(Name = "Business Unit")]
|
|
public Guid? ParentCompanyId { get; set; }
|
|
[Display(Name = "Business Unit")]
|
|
public string ParentCompanyName { get; set; }
|
|
[Display(Name = "Number of Projects")]
|
|
public int ProjectsCount { get; set; }
|
|
[Display(Name = "Number of Business Units")]
|
|
public int CompaniesCount { get; set; }
|
|
[Display(Name = "Number of Teams")]
|
|
public int TeamsCount { get; set; }
|
|
|
|
public IList<Guid> ClientId { get; set; }
|
|
public IList<Guid> ViewId { get; set; }
|
|
|
|
[Display(Name = "Business Unit Watchers")]
|
|
public List<Guid> Watchers { get; set; }
|
|
public string WatchersAsText
|
|
{
|
|
get
|
|
{
|
|
string result = String.Empty;
|
|
|
|
if ((this.Watchers != null) && (this.Watchers.Count > 0))
|
|
{
|
|
foreach (Guid userId in this.Watchers)
|
|
{
|
|
result += "," + userId.ToString();
|
|
}
|
|
result = result.Substring(1);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
[Display(Name = "Business Unit Contributors")]
|
|
public List<Guid> Contributors { get; set; }
|
|
public string ContributorsAsText
|
|
{
|
|
get
|
|
{
|
|
string result = String.Empty;
|
|
|
|
if ((this.Contributors != null) && (this.Contributors.Count > 0))
|
|
{
|
|
foreach (Guid userId in this.Contributors)
|
|
{
|
|
result += "," + userId.ToString();
|
|
}
|
|
result = result.Substring(1);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copies data from model to DAL object.
|
|
/// </summary>
|
|
/// <param name="dbObj">A target DAL object.</param>
|
|
public void CopyTo(Company dbObj)
|
|
{
|
|
if (dbObj == null)
|
|
throw new ArgumentNullException();
|
|
|
|
dbObj.Name = Name;
|
|
dbObj.ParentCompanyId = ParentCompanyId;
|
|
}
|
|
}
|
|
|
|
public class CompanyApiModel
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string Name { get; set; }
|
|
public Guid? ParentCompanyId { get; set; }
|
|
|
|
#region Constructors
|
|
|
|
public CompanyApiModel()
|
|
{
|
|
|
|
}
|
|
|
|
public CompanyApiModel(CompanyModel model)
|
|
: this()
|
|
{
|
|
if (model == null)
|
|
throw new ArgumentNullException("model");
|
|
|
|
Id = model.Id;
|
|
Name = model.Name;
|
|
ParentCompanyId = model.ParentCompanyId;
|
|
}
|
|
|
|
public CompanyApiModel(Company model)
|
|
: this()
|
|
{
|
|
if (model == null)
|
|
throw new ArgumentNullException("model");
|
|
|
|
Id = model.Id;
|
|
Name = model.Name;
|
|
ParentCompanyId = model.ParentCompanyId;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |