using EnVisage.Code; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace EnVisage.Models { public class ScenarioTabModel { #region Properties public System.Guid Id { get; set; } public Guid ProjectId { get; set; } public string ProjectName { get; set; } public ScenarioType? Type { get; set; } public string Name { get; set; } public Nullable ProjectedRevenue { get; set; } public Nullable ExpectedGrossMargin { get; set; } public Nullable CalculatedGrossMargin { get; set; } public Nullable StartDate { get; set; } public Nullable EndDate { get; set; } public Nullable Shots { get; set; } public bool FreezeRevenue { get; set; } public Nullable Status { get; set; } public List WorkFlowStatesForTeams { get; set; } #endregion #region Constructors public ScenarioTabModel() { } #endregion #region Methods /// /// Casts a obect to the object of type . /// /// A object. /// A object filled with data from db. public static explicit operator ScenarioTabModel(Scenario obj) { if (obj == null) return null; var model = new ScenarioTabModel { Id = obj.Id, ProjectId = obj.ParentId ?? Guid.Empty, ProjectName = obj.Project != null ? obj.Project.Name : "", Name = obj.Name, Type = (ScenarioType)obj.Type, EndDate = obj.EndDate.HasValue ? obj.EndDate.Value.Date : (DateTime?)null, StartDate = obj.StartDate.HasValue ? obj.StartDate.Value.Date : (DateTime?)null, ProjectedRevenue = obj.ProjectedRevenue, ExpectedGrossMargin = obj.ExpectedGrossMargin ?? 0, CalculatedGrossMargin = obj.CalculatedGrossMargin ?? 0, Shots = obj.Shots ?? 0, FreezeRevenue = obj.FreezeRevenue, Status = (obj.Status.HasValue ? (ScenarioStatus)obj.Status.Value : ScenarioStatus.Inactive), }; model.WorkFlowStatesForTeams = new List(); model.TrimStringProperties(); return model; } #endregion } }