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 }); }
public static TempClosureReopenMemo Get(string projectId) { var db = PrepareDb(); var usCode = db.ProjectInfo.FirstOrDefault(pi => pi.ProjectId == projectId).USCode; var reopenMemo = FirstOrDefault(cm => cm.ProjectId == projectId); if (reopenMemo == null) { reopenMemo = SqlQuery <TempClosureReopenMemo>(@" SELECT CAST('00000000-0000-0000-0000-000000000000' AS uniqueidentifier) [Id] ,@ProjectId [ProjectId] ,@USCode [USCode] ,s.RegionCode [RegionCode] ,s.RegionENUS [RegionENUS] ,s.RegionZHCN [RegionZHCN] ,s.MarketCode [MarketCode] ,s.MarketENUS [MarketENUS] ,s.MarketZHCN [MarketZHCN] ,s.ProvinceENUS [ProvinceENUS] ,s.ProvinceZHCN [ProvinceZHCN] ,s.CityCode [CityCode] ,s.CityENUS [CityENUS] ,s.CityZHCN [CityZHCN] ,s.NameENUS [StoreENUS] ,s.NameZHCN [StoreZHCN] ,'' [PipelineId] ,NULL MarketDesirability ,NULL RERating ,NULL [ActualConsFinishDate] ,ci.ActualReopenDate [OpeningDate] ,s.PortfolioType [PortfolioType] ,s.PortfolioTypeName [ProtfolioTypeName] ,s.TACode [TAClassification] ,s.TAName [TAClassificationName] ,cast(cast(isnull(sloc.Seats1,0) as decimal)+cast(isnull(sloc.Seats2,0) as decimal) +cast(isnull(sloc.Seats3,0) as decimal)+cast(isnull(sloc.Seats4,0) as decimal) +cast(isnull(sloc.Seats5,0) as decimal) as nvarchar(10)) SeatingNum ,sloc.TotalArea [BusinessArea] ,sloc.KitchenFloor [KitchenFloor] ,sloc.Floor [SeatingFloor] ,'' [EarlyTerminationClause] ,NULL CarParkTotal ,sloc.KitchenFloor [ParkingNum] ,'' [ContractType] ,'' [Kiosk] ,sd.AssetRepEid [RERep] ,sd.PlannerEid [Planner] ,sd.RERepName RERepName ,sd.PlannerName PlannerName ,@Creator Creator ,getdate() CreateTime FROM StoreBasicInfo s INNER JOIN StoreSTLocation sloc ON sloc.StoreCode = s.StoreCode INNER JOIN StoreDevelop sd ON sd.StoreCode = s.StoreCode INNER JOIN TempClosureInfo ci ON ci.USCode = s.StoreCode WHERE s.StoreCode = @USCode AND ci.ProjectId = @ProjectId ", new { ProjectId = projectId, USCode = usCode, Creator = ClientCookie.UserCode }).FirstOrDefault(); var contractType = StoreContractInfo.SearchByProject(projectId).OrderByDescending(c => c.CreatedTime).Select(c => c.LeasePurchase).FirstOrDefault(); var taInfo = StoreMMInfo.Search(ta => ta.StoreCode == usCode).Select(ta => new { Desirability = ta.Desirability, LocationRatingPP = ta.LocationRatingPP }).FirstOrDefault(); var dic_contractType = Dictionary.GetDictionary(contractType); reopenMemo.ContractType = dic_contractType == null ? "" : dic_contractType.NameZHCN; var dic_desirability = Dictionary.GetDictionary(taInfo.Desirability); reopenMemo.MarketDesirability = dic_desirability == null ? "" : dic_desirability.NameZHCN; var dic_locationRatingPP = Dictionary.GetDictionary(taInfo.LocationRatingPP); reopenMemo.RERating = dic_locationRatingPP == null ? "" : dic_locationRatingPP.NameZHCN; var tempMemo = TempClosureMemo.GetTempClosureMemo(projectId); if (tempMemo != null) { reopenMemo.TempCloseDate = tempMemo.ClosureDate; } } return(reopenMemo); }