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);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 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));
 }