示例#1
0
 /// <summary>
 /// This method only should be used in MajorLease(Create) or Rebuild(Package)
 /// </summary>
 public void Append()
 {
     using (TransactionScope tranScope = new TransactionScope())
     {
         if (this.Id == Guid.Empty)
         {
             this.Id = Guid.NewGuid();
         }
         if (!ProjectContractInfo.Any(e => e.ProjectId == this.ProjectId))
         {
             var contract = StoreContractInfo.GetCurrentContract(this.ProjectId);
             Mapper.CreateMap <StoreContractInfo, ProjectContractInfo>();
             var projContract = Mapper.Map <ProjectContractInfo>(contract);
             projContract.ContractInfoId = contract.Id;
             if (!string.IsNullOrEmpty(contract.BGCommencementDate))
             {
                 projContract.BGCommencementDate = DateTime.Parse(contract.BGCommencementDate);
             }
             if (!string.IsNullOrEmpty(contract.BGEndDate))
             {
                 projContract.BGEndDate = DateTime.Parse(contract.BGEndDate);
             }
             projContract.Id        = Guid.NewGuid();
             projContract.ProjectId = this.ProjectId;
             projContract.Add();
         }
         var revisions = ProjectContractRevision.Get(this.ProjectId, this.ProjectContractId);
         var oldRev    = revisions.FirstOrDefault(e => e.ProjectId == this.ProjectId);
         if (oldRev == null)
         {
             revisions.Add(this);
         }
         else
         {
             oldRev.ChangeDate           = this.ChangeDate;
             oldRev.Description          = this.Description;
             oldRev.Entity               = this.Entity;
             oldRev.LandlordNew          = this.LandlordNew;
             oldRev.LandlordOld          = this.LandlordOld;
             oldRev.LeaseTerm            = this.LeaseTerm;
             oldRev.LeaseChangeExpiryNew = this.LeaseChangeExpiryNew;
             oldRev.LeaseChangeExpiryOld = this.LeaseChangeExpiryOld;
             oldRev.Others               = this.Others;
             oldRev.OthersDescription    = this.OthersDescription;
             oldRev.Rent             = this.Rent;
             oldRev.RentStructureNew = this.RentStructureNew;
             oldRev.RentStructureOld = this.RentStructureOld;
             oldRev.Size             = this.Size;
             oldRev.RedlineAreaNew   = this.RedlineAreaNew;
             oldRev.RedlineAreaOld   = this.RedlineAreaOld;
         }
         revisions.ForEach(r => r.Save());
         tranScope.Complete();
     }
 }
示例#2
0
        public static ProjectContractInfo Get(string projectId)
        {
            var contract = FirstOrDefault(c => c.ProjectId == projectId);

            if (contract == null)
            {
                var storeContract = StoreContractInfo.GetCurrentContract(projectId);
                Mapper.CreateMap <StoreContractInfo, ProjectContractInfo>();
                contract = Mapper.Map <ProjectContractInfo>(storeContract);
                contract.ContractInfoId = storeContract.Id;
                if (!string.IsNullOrEmpty(storeContract.BGCommencementDate))
                {
                    contract.BGCommencementDate = DateTime.Parse(storeContract.BGCommencementDate);
                }
                if (!string.IsNullOrEmpty(storeContract.BGEndDate))
                {
                    contract.BGEndDate = DateTime.Parse(storeContract.BGEndDate);
                }
                contract.Id        = Guid.NewGuid();
                contract.ProjectId = projectId;
            }
            return(contract);
        }
示例#3
0
        public static ProjectContractDto GetContractWithHistory(string projectId)
        {
            var contract = Search(c => c.ProjectId == projectId).OrderByDescending(c => c.CreatedTime).FirstOrDefault(c => c.ProjectId == projectId);

            if (contract == null)
            {
                var storeContract = StoreContractInfo.GetCurrentContract(projectId);
                Mapper.CreateMap <StoreContractInfo, ProjectContractInfo>();
                contract = Mapper.Map <ProjectContractInfo>(storeContract);
                contract.ContractInfoId = storeContract.Id;
                contract.Id             = Guid.NewGuid();
                //if (contract.McDLegalEntity != null && contract.McDLegalEntity.StartsWith("suoya"))
                //    contract.McDLegalEntity = Dictionary.Search(d => d.Value == contract.McDLegalEntity).FirstOrDefault().NameZHCN;
                //if (contract.McDOwnership != null && contract.McDOwnership.StartsWith("suoya"))
                //    contract.McDOwnership = Dictionary.Search(d => d.Value == contract.McDOwnership).FirstOrDefault().NameZHCN;
                //if (contract.LeasePurchase != null && contract.LeasePurchase.StartsWith("suoya"))
                //    contract.LeasePurchase = Dictionary.Search(d => d.Value == contract.LeasePurchase).FirstOrDefault().NameZHCN;
                //if (contract.RentPaymentArrangement != null && contract.RentPaymentArrangement.StartsWith("suoya"))
                //    contract.RentPaymentArrangement = Dictionary.Search(d => d.Value == contract.RentPaymentArrangement).FirstOrDefault().NameZHCN;
                contract.ProjectId = projectId;
            }
            var histories = StoreContractInfo.SearchByProject(projectId).Skip(1).ToList().Select(c =>
            {
                Mapper.CreateMap <StoreContractInfo, ProjectContractInfo>();
                var history            = Mapper.Map <ProjectContractInfo>(c);
                history.ContractInfoId = c.Id;
                history.ProjectId      = projectId;
                return(history);
            }).ToList();

            return(new ProjectContractDto
            {
                Current = contract,
                Histories = histories
            });
        }