68 lines
2.5 KiB
C#
68 lines
2.5 KiB
C#
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<decimal> ProjectedRevenue { get; set; }
|
|
public Nullable<decimal> ExpectedGrossMargin { get; set; }
|
|
public Nullable<decimal> CalculatedGrossMargin { get; set; }
|
|
public Nullable<System.DateTime> StartDate { get; set; }
|
|
public Nullable<System.DateTime> EndDate { get; set; }
|
|
public Nullable<int> Shots { get; set; }
|
|
public bool FreezeRevenue { get; set; }
|
|
public Nullable<ScenarioStatus> Status { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
public ScenarioTabModel()
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
/// <summary>
|
|
/// Casts a <see cref="Scenario"/> obect to the object of type <see cref="ScenarioModel"/>.
|
|
/// </summary>
|
|
/// <param name="obj">A <see cref="Scenario"/> object.</param>
|
|
/// <returns>A <see cref="ScenarioTabModel"/> object filled with data from db.</returns>
|
|
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 = obj.Type == null ? (ScenarioType?)null : (ScenarioType)obj.Type,
|
|
EndDate = obj.EndDate,
|
|
StartDate = obj.StartDate,
|
|
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.TrimStringProperties();
|
|
return model;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |