public static StoreInfo GetStore(string usCode) { string _USCode = usCode; List <StoreBasicInfo> lsStoreBasicInfo = new List <StoreBasicInfo>(); StoreBasicInfo mStoreBasicInfo = new StoreBasicInfo(); lsStoreBasicInfo = StoreBasicInfo.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking().ToList <StoreBasicInfo>(); if (lsStoreBasicInfo.Count > 0) { mStoreBasicInfo = lsStoreBasicInfo[0]; } List <StoreDevelop> lsStoreDevelop = new List <StoreDevelop>(); StoreDevelop mStoreDevelop = new StoreDevelop(); lsStoreDevelop = StoreDevelop.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking().ToList <StoreDevelop>(); if (lsStoreDevelop.Count > 0) { mStoreDevelop = lsStoreDevelop[0]; } List <StoreOps> lsStoreOp = new List <StoreOps>(); StoreOps mStoreOp = new StoreOps(); lsStoreOp = StoreOps.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking().ToList <StoreOps>(); if (lsStoreOp.Count > 0) { mStoreOp = lsStoreOp[0]; } List <StoreContractInfo> lsStoreContractInfo = new List <StoreContractInfo>(); StoreContractInfo mStoreContractInfo = new StoreContractInfo(); lsStoreContractInfo = StoreContractInfo.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking() .OrderByDescending(o => o.CreatedTime).ToList <StoreContractInfo>(); if (lsStoreContractInfo.Count > 0) { mStoreContractInfo = lsStoreContractInfo[0]; } List <StoreSTLocation> lsStoreSTLocation = new List <StoreSTLocation>(); StoreSTLocation mStoreSTLocation = new StoreSTLocation(); lsStoreSTLocation = StoreSTLocation.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking().ToList <StoreSTLocation>(); if (lsStoreSTLocation.Count > 0) { mStoreSTLocation = lsStoreSTLocation[0]; } List <StoreSTLLRecord> lsStoreSTLLRecord = new List <StoreSTLLRecord>(); StoreSTLLRecord mStoreSTLLRecord = new StoreSTLLRecord(); lsStoreSTLLRecord = StoreSTLLRecord.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking().ToList <StoreSTLLRecord>(); if (lsStoreSTLLRecord.Count > 0) { mStoreSTLLRecord = lsStoreSTLLRecord[0]; } int?beId = StoreBEInfo.Search(o => o.StoreCode.Contains(_USCode)).AsNoTracking().Select(be => be.BEID).FirstOrDefault(); StoreBEContractInfo storeBeContractInfo = StoreBEContractInfo.FirstOrDefault(c => c.BEID == beId); //StoreContractRevision = new StoreContractRevision(), // StoreContractInfoAttached = new StoreContractInfoAttached() var lsStoreBEInfo = StoreBEInfo.Search(o => o.StoreCode == _USCode).AsNoTracking().ToList <StoreBEInfo>(); List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); List <StoreBEInfo> mdsList = new List <StoreBEInfo>(); List <StoreBEInfo> mcCafeList = new List <StoreBEInfo>(); List <StoreBEInfo> hour24List = new List <StoreBEInfo>(); if (lsStoreBEInfo.Count > 0) { foreach (var beInfo in lsStoreBEInfo) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attached Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mdsList.Add(beInfo); break; case "McCafe": mcCafeList.Add(beInfo); break; case "24 Hour": hour24List.Add(beInfo); break; } } } var resultStoreAllInfo = new StoreInfo { StoreBasicInfo = mStoreBasicInfo, StoreDevelop = mStoreDevelop, StoreOp = mStoreOp, StoreContractInfo = mStoreContractInfo, StoreSTLocation = mStoreSTLocation, StoreSTLLRecord = mStoreSTLLRecord, StoreBeContractInfo = storeBeContractInfo, StoreBEInfoList = lsStoreBEInfo, CurrentYear = DateTime.Now.Year, RemoteBeCount = remoteBeList.Count, AttachedBeCount = attachedBeList.Count, MDSBeCount = mdsList.Count, MCCafeCount = mcCafeList.Count, Hour24Count = hour24List.Count }; return(resultStoreAllInfo); }
private static RenewalAnalysisStoreInfo PrepareStoreInfo(string projectId, string usCode) { var store = StoreBasicInfo.GetStorInfo(usCode); var storeMMInfo = StoreMMInfo.Get(usCode); var storeContract = StoreContractInfo.Get(usCode); var ta = StoreSTLocation.GetStoreSTLocation(usCode); var tool = RenewalTool.Get(projectId); var finOutput = RenewalToolFinMeasureOutput.GetByToolId(tool.Id) ?? new RenewalToolFinMeasureOutput(); var consInfo = RenewalConsInfo.Get(projectId); var toolWriteOff = RenewalToolWriteOffAndReinCost.Get(projectId, tool.Id); var floors = string.Join("/", new[] { string.Join(",", new[] { ta.Floor1, ta.Floor2, ta.Floor3, ta.Floor4, ta.Floor5 }.Where(e => !string.IsNullOrEmpty(e)).ToArray()), string.Join(",", new[] { ta.FrontCounterFloor1, ta.FrontCounterFloor2 }.Where(e => !string.IsNullOrEmpty(e)).ToArray()) }.Where(e => !string.IsNullOrEmpty(e)).ToArray()); var seats = string.Join("/", new[] { new[] { ta.Seats1, ta.Seats2, ta.Seats3, ta.Seats4, ta.Seats5, ta.FrontCounterSeats }.Select(e => { var val = 0; int.TryParse(e, out val); return(val); }).Sum(), string.IsNullOrEmpty(ta.OutsideSeats)?0:int.Parse(ta.OutsideSeats) }); var beTypes = string.Join(",", StoreBEInfo.Search(e => e.StoreCode == usCode && e.BETypeName != "FC" && e.BETypeName != "DT").Select(e => e.BETypeName).ToArray()); var leaseTenureAndTerm = string.Concat(storeContract.LeasePurchaseTerm, " years,from ", storeContract.StartDate.HasValue ? storeContract.StartDate.Value.ToString("yyyy-MM-dd") : " / ", "to", storeContract.EndDate.HasValue ? storeContract.EndDate.Value.ToString("yyyy-MM-dd") : " / " ); return(new RenewalAnalysisStoreInfo { UsCode = store.StoreCode, NameZHCN = store.NameZHCN, NameENUS = store.NameENUS, MinimarketPriority = storeMMInfo.Priority, TADesrability = storeMMInfo.Desirability, SitePortfolioType = storeMMInfo.PortfolioTypeName, SiteRerating = storeMMInfo.LocationRatingPP, LeasedArea = storeContract.TotalLeasedArea, OperationSize = ta.TotalArea, Floors = floors, Seats = seats, BEType = beTypes, LeaseTenureAndTerm = leaseTenureAndTerm, FreeRentalPeriod = storeContract.FreeRentalPeriod, RentStructure = storeContract.RentStructure, DRMFLastTY = finOutput.AnnualRentExpenseLY, DRMFLastTYSales = finOutput.RentAsProdSalesLY, SRMFLastTY = finOutput.AnnualRentExpenseYr1, SRMFLastTYSales = finOutput.RentAsProdSalesYr1, SRMF1stTY = finOutput.AnnualRentExpenseAvg, SRMF1stTYSales = finOutput.RentAsProdSalesAvg, AnnualSOILastTY = finOutput.SOIProdSalesLY, AnnualSOIAvg = finOutput.SOIProdSalesAvg, CashROIAvg = finOutput.CashROIAvg, CashROILastTY = finOutput.CashROILY, OriginalInvestment = (toolWriteOff.REII + toolWriteOff.LHIII + toolWriteOff.ESSDII).ToString(), NBV = (toolWriteOff.RENBV + toolWriteOff.LHINBV + toolWriteOff.ESSDNBV).ToString(), AdditionalInvestmentCost = (toolWriteOff.RECost + toolWriteOff.LHICost + toolWriteOff.ESSDCost).ToString(), ExclusivityClause = storeContract.ExclusivityClause, McDsEarlyTerminationRight = storeContract.WithEarlyTerminationClause == null || storeContract.WithEarlyTerminationClause == 0 ? "N" : "Y", LandlordEntity = storeContract.PartyAFullName, LastRemodeling = store.ReImageDate.HasValue ? store.ReImageDate.Value.ToString("yyyy-MM-dd") : "" }); }