| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace GreenTree.Nachtragsmanagement.Web.Models.Deviation
- {
- public class DeviationDataModel
- {
- public int Id { get; set; }
- public string CustomNumber { get; set; }
- public DateTime ReceiptDate { get; set; }
- public decimal Value { get; set; }
- public int StatusId { get; set; }
- public string StatusDescription { get; set; }
- public int DisturbanceId { get; set; }
- public string DisturbanceDescription { get; set; }
- public int KindId { get; set; }
- public string KindDescription { get; set; }
- public string Comment { get; set; }
- public string AppendixDescription { get; set; }
- public int? AppendixId { get; set; }
- public static DeviationDataModel FromDeviation(Core.Domain.Deviation.Deviation deviationEntity, bool newWhenIsNull)
- {
- if (deviationEntity == null && newWhenIsNull)
- return new DeviationDataModel
- {
- Id = -1
- };
- if (deviationEntity == null && !newWhenIsNull)
- throw new ArgumentNullException("deviationEntity", "Cannot create DeviationDataModel from NULL deviation entity.");
- return new DeviationDataModel
- {
- Id = deviationEntity.Id,
- CustomNumber = deviationEntity.CustomNumber,
- ReceiptDate = deviationEntity.ReceiptDate,
- Value = deviationEntity.Value.Value,
- AppendixId = deviationEntity.AppendixId,
- AppendixDescription = deviationEntity.Appendix == null
- ? null
- : deviationEntity.Appendix.CustomNumber,
- StatusId = deviationEntity.StatusId.Value,
- StatusDescription = deviationEntity.Status == null
- ? null
- : deviationEntity.Status.Description,
- DisturbanceId = deviationEntity.DisturbanceId.Value,
- DisturbanceDescription = deviationEntity.Disturbance == null
- ? null
- : deviationEntity.Disturbance.Description,
- KindId = deviationEntity.KindId.Value,
- KindDescription = deviationEntity.Kind == null
- ? null
- : deviationEntity.Kind.Description,
- Comment = deviationEntity.Comment
- };
- }
- public Core.Domain.Deviation.Deviation ToDeviation()
- {
- return new Core.Domain.Deviation.Deviation
- {
- Id = this.Id,
- CustomNumber = this.CustomNumber,
- ReceiptDate = this.ReceiptDate,
- Value = this.Value,
- AppendixId = this.AppendixId,
- StatusId = this.StatusId,
- DisturbanceId = this.DisturbanceId,
- KindId = this.KindId,
- Comment = this.Comment
- };
- }
- }
- }
|