public int Create( string title, string description, string address, string contact, int constructionYear, int?sellingPrice, int?rentingPrice, RealEstateType type, string userId) { RealEstate realEstate = new RealEstate() { Title = title, Description = description, Address = address, Contact = contact, ConstructionYear = constructionYear, SellingPrice = sellingPrice, RentingPrice = rentingPrice, RealEstateType = type, CanBeSold = sellingPrice == null ? false : true, CanBeRented = rentingPrice == null ? false : true, UserId = userId }; this.realEstateRepository.Add(realEstate); this.realEstateRepository.SaveChanges(); return(realEstate.Id); }
public RealEstate CreateRealEstate(string title, string description, string address, string contact, int constructionYear, int? sellingPrice, int? rentingPrice, RealEstateType type, string userId) { var estate = new RealEstate { Title = title, Description = description, Address = address, Contact = contact, ConstructionYear = constructionYear, SellingPrice = sellingPrice, RentingPrice = rentingPrice, RealEstateType = type, CreatedOn = DateTime.UtcNow, UserId = userId }; this.realestates.Add(estate); this.realestates.SaveChanges(); return estate; }
public static double GetAverageBedsByRealEstateTypeAndCityHigherThanPrice(List <RealEstateSale> realEstateDataList, RealEstateType realEstateType, string city, decimal price) { //Must round to 2 decimal points return(Math.Round(Convert.ToDouble(realEstateDataList.Where(x => x.Type == realEstateType && x.City.ToLower() == city.ToLower() && x.Price > price).Average(x => x.Beds)), 2)); }