| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace GreenTree.Nachtragsmanagement.Web.Models.Appendix
- {
- public class AppendixDataModel
- {
- public int Id { get; set; }
- public string CustomNumber { get; set; }
- public string Description { get; set; }
- public decimal? Probability { get; set; }
- public int? OfferingNumber { get; set; }
- public DateTime? OfferingDate { get; set; }
- public DateTime? NegotiationDate { get; set; }
- public decimal? NegotiationValue { get; set; }
- public bool ProtocolExists { get; set; }
- public int? OrderNumber { get; set; }
- public DateTime? OrderDate { get; set; }
- public string Comment { get; set; }
- public int? SiteId { get; set; }
- public string SiteDescription { get; set; }
- public ICollection<int> CategoryValues { get; set; }
- public ICollection<string> CategoryDescriptions { get; set; }
- public ICollection<int> DeviationValues { get; set; }
- public ICollection<string> DeviationDescriptions { get; set; }
- public static AppendixDataModel FromAppendix(Core.Domain.Appendix.Appendix appendixEntity, bool newWhenIsNull)
- {
- if (appendixEntity == null && newWhenIsNull)
- return new AppendixDataModel
- {
- Id = -1
- };
- if (appendixEntity == null && !newWhenIsNull)
- throw new ArgumentNullException("appendixEntity", "Cannot create AppendixDataModel from NULL appendix entity.");
- return new AppendixDataModel
- {
- Id = appendixEntity.Id,
- CustomNumber = appendixEntity.CustomNumber,
- Description = appendixEntity.Description,
- Probability = appendixEntity.Probability,
- OfferingNumber = appendixEntity.OfferingNumber,
- OfferingDate = appendixEntity.OfferingDate,
- NegotiationDate = appendixEntity.NegotiationDate,
- NegotiationValue = appendixEntity.NegotiationValue,
- ProtocolExists = appendixEntity.ProtocolExists,
- OrderNumber = appendixEntity.OrderNumber,
- OrderDate = appendixEntity.OrderDate,
- Comment = appendixEntity.Comment,
- SiteId = appendixEntity.SiteId,
- SiteDescription = appendixEntity.Site == null
- ? null
- : appendixEntity.Site.Description,
- CategoryValues =
- appendixEntity.CategoryValues
- .Select(r => r.Id)
- .ToList(),
- CategoryDescriptions =
- appendixEntity.CategoryValues
- .Select(r => r.Category == null
- ? String.Empty
- : r.Category.Description)
- .ToList(),
- DeviationValues =
- appendixEntity.Deviations
- .Select(r => r.Id)
- .ToList(),
- DeviationDescriptions =
- appendixEntity.Deviations
- .Select(r => r.CustomNumber)
- .ToList()
- };
- }
- public Core.Domain.Appendix.Appendix ToAppendix()
- {
- return new Core.Domain.Appendix.Appendix
- {
- Id = this.Id,
- CustomNumber = this.CustomNumber,
- Description = this.Description,
- Probability = this.Probability,
- OfferingNumber = this.OfferingNumber,
- OfferingDate = this.OfferingDate,
- NegotiationDate = this.NegotiationDate,
- NegotiationValue = this.NegotiationValue,
- ProtocolExists = this.ProtocolExists,
- OrderNumber = this.OrderNumber,
- OrderDate = this.OrderDate,
- Comment = this.Comment,
- SiteId = this.SiteId
- };
- }
- }
- }
|