Beispiel #1
0
        public bool CreateRealEstateProperty(RealEstatePropertyCreate model)
        {
            var entity =
                new RealEstateProperty()
            {
                RealEstatePropertyName = model.RealEstatePropertyName,
                ImageLink         = model.ImageLink,
                SquareFootage     = model.SquareFootage,
                RealEstateAddress = model.RealEstateAddress,
                RealEstateCity    = model.RealEstateCity,
                RealEstateState   = model.RealEstateState,
                RealEstateZip     = model.RealEstateZip,
                PropertyType      = model.PropertyType,
                HasBasement       = model.HasBasement,
                HasPool           = model.HasPool,
                Bedroom           = model.Bedroom,
                Bathroom          = model.Bathroom,
                Stories           = model.Stories
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.RealEstateProperty.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Post(RealEstatePropertyCreate realEstateProperty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateRealEstatePropertyService();

            if (!service.CreateRealEstateProperty(realEstateProperty))
            {
                return(InternalServerError());
            }

            return(Ok());
        }