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

50 lines
1.4 KiB
C#

using System;
using System.ComponentModel.DataAnnotations;
using EnVisage.Code;
namespace EnVisage.Models
{
public class ScenarioGroupModel : IBaseModel<SystemAttribute>
{
public Guid Id { get; set; }
[Required]
[MaxLength(50)]
[Display(Name="Scenario Type")]
public string Name { get; set; }
public int Type => 3;
/// <summary>
/// Casts a <see cref="UOM"/> obect to the object of type <see cref="UOMModel"/>.
/// </summary>
/// <param name="obj">A <see cref="UOM"/> object.</param>
/// <returns>A <see cref="UOMModel"/> object filled with data from db.</returns>
public static explicit operator ScenarioGroupModel(SystemAttribute obj)
{
if (obj == null)
return null;
var model = new ScenarioGroupModel
{
Id = obj.Id,
Name = obj.Name
};
model.TrimStringProperties();
return model;
}
/// <summary>
/// Copies data from model to DAL object.
/// </summary>
/// <param name="dbObj">A target DAL object.</param>
public void CopyTo(SystemAttribute dbObj)
{
if (dbObj == null)
throw new ArgumentNullException();
dbObj.Name = Name;
}
}
}