public static string GetRentalContract() { using (var courceProjectItems = new CourceProjectDbContext()) { var tenantsRental = courceProjectItems.TenantRentalPremises.ToList(); StringBuilder sb = new StringBuilder(); float cost; float totalCost = 0; foreach (var item in tenantsRental) { cost = ArendetPremisesPageGeneration.TotalRentalCost(item.RentalPremisesId); totalCost += cost; sb.Append("Tenant: " + item.FullName + "\nAdress: " + item.Adress + "\nRental Number: " + item.RentalNumber + "\nArea: " + courceProjectItems.RentalPremises.Where(a => a.RentalPremisesId == item.RentalPremisesId).Select(a => a.Area).FirstOrDefault() + "\nPrice: " + courceProjectItems.RentalPremises.Where(a => a.RentalPremisesId == item.RentalPremisesId).Select(a => a.Price).FirstOrDefault() + "\nRental Begin Date: " + courceProjectItems.RentalPremises.Where(a => a.RentalPremisesId == item.RentalPremisesId).Select(a => a.RentalBeginDate).FirstOrDefault() + "\nRental End Date: " + courceProjectItems.RentalPremises.Where(a => a.RentalPremisesId == item.RentalPremisesId).Select(a => a.RentalEndDate).FirstOrDefault() + "\nProfit: " + cost); sb.Append("\n------------------------------------------------------------\n"); } sb.Append("\n Total profit: " + totalCost); return(sb.ToString()); } }
public static string GetRentalPramses(string login) { using (var userItems = new CourceProjectDbContext()) { var buildingsItems = new CourceProjectDbContext(); var premisesList = buildingsItems.RentalPremises.Where(a => a.RentalBeginDate != null && a.RentalCheck == false).ToList(); var adress = buildingsItems.RentalPremises.Where(a => a.RentalBeginDate != null && a.RentalCheck == false).Select(a => a.Building.Adress).ToList(); float cost; float totalCost = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < adress.Count; i++) { cost = ArendetPremisesPageGeneration.TotalRentalCost(premisesList[i].RentalPremisesId); totalCost += cost; sb.Append("Adress: " + adress[i] + premisesList[i].ToString() + "Cost: " + cost + "\n"); sb.Append("------------------------------------------------------------\n"); } sb.Append("Total Cost: " + totalCost); return(sb.ToString()); } }