Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Alphafolio.DAL;
- using Alphafolio.DAL.Model;
- using Alphafolio.Tools;
- using Alphafolio.Tools.Configuration;
- using Alphafolio.Tools.ObjectInfos;
- using Alphafolio.WebApp.Models.UIKendo;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- namespace Alphafolio.WebApp.Models.VmContract
- {
- public class VmGridCommitments : IValidatableObject
- {
- public string Id { get; set; }
- public ContractObjectInfo ItemObjectInfo { get; set; }
- public VmLockItem PageLock { get; set; }
- public Nullable<decimal> Amount { get; set; }
- public Nullable<decimal> ExchangeRate { get; set; }
- public Nullable<System.DateTime> Date { get; set; }
- public string Status { get; set; }
- public string Comments { get; set; }
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- if (!Amount.HasValue)
- yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "Amount" });
- if (!ExchangeRate.HasValue)
- yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "ExchangeRate" });
- if (!Date.HasValue)
- yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "Date" });
- if (String.IsNullOrWhiteSpace(Status))
- yield return new ValidationResult(TranslationManager.TranslateItem("valRequiredField", "AdHoc"), new[] { "Status" });
- }
- public VmPopupDocuments VmPopup
- {
- get
- {
- return new VmPopupDocuments(new Guid(Id), ObjectType.Contract, ObjectSubType.ContractCommitment);
- }
- }
- internal static VmGridCommitments Get(Guid id)
- {
- using (AIEntities ai = ConnectionHelper.GetContext())
- {
- Contract bdd = ai.ContractSet.FirstOrDefault(a => a.Id == id);
- VmGridCommitments result = VmGridCommitments.FromDAL(bdd);
- return result;
- }
- }
- private static VmGridCommitments FromDAL(Contract bdd)
- {
- VmGridCommitments result = AutoMapperHelper.AutoMap<Contract, VmGridCommitments>(bdd);
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement