Advertisement
Guest User

rapport

a guest
Feb 28th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. using Alphafolio.DAL;
  2. using Alphafolio.DAL.Model;
  3. using Alphafolio.Tools;
  4. using Alphafolio.Tools.Configuration;
  5. using Alphafolio.Tools.ObjectInfos;
  6. using Alphafolio.WebApp.Models.UIKendo;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel.DataAnnotations;
  10. using System.Linq;
  11.  
  12. namespace Alphafolio.WebApp.Models.VmContract
  13. {
  14.     public class VmGridCommitments : IValidatableObject
  15.     {
  16.         public string Id { get; set; }
  17.         public ContractObjectInfo ItemObjectInfo { get; set; }
  18.         public VmLockItem PageLock { get; set; }
  19.  
  20.         public Nullable<decimal> Amount { get; set; }
  21.         public Nullable<decimal> ExchangeRate { get; set; }
  22.         public Nullable<System.DateTime> Date { get; set; }
  23.         public string Status { get; set; }
  24.         public string Comments { get; set; }
  25.  
  26.         public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  27.         {
  28.             if (!Amount.HasValue)
  29.                 yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "Amount" });
  30.  
  31.             if (!ExchangeRate.HasValue)
  32.                 yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "ExchangeRate" });
  33.  
  34.             if (!Date.HasValue)
  35.                 yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "Date" });
  36.  
  37.             if (String.IsNullOrWhiteSpace(Status))
  38.                 yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "Status" });
  39.         }
  40.  
  41.         public VmPopupDocuments VmPopup
  42.         {
  43.             get
  44.             {
  45.                 return new VmPopupDocuments(new Guid(Id), ObjectType.Contract, ObjectSubType.ContractCommitment);
  46.             }
  47.         }
  48.  
  49.  
  50.         internal static VmGridCommitments Get(Guid id)
  51.         {
  52.             using (AIEntities ai = ConnectionHelper.GetContext())
  53.             {
  54.                 Contract bdd = ai.ContractSet.FirstOrDefault(a => a.Id == id);
  55.                 VmGridCommitments result = VmGridCommitments.FromDAL(bdd);
  56.                 return result;
  57.             }
  58.         }
  59.  
  60.         private static VmGridCommitments FromDAL(Contract bdd)
  61.         {
  62.             VmGridCommitments result = AutoMapperHelper.AutoMap<Contract, VmGridCommitments>(bdd);
  63.             return result;
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement