示例#1
0
        public bool RealEstatePropertyUpdate(RealEstatePropertyUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .RealEstateProperty
                    .Single(e => e.RealEstatePropertyId == model.RealEstatePropertyId);
                entity.RealEstatePropertyName = model.RealEstatePropertyName;
                entity.ImageLink         = model.ImageLink;
                entity.SquareFootage     = model.SquareFootage;
                entity.RealEstateAddress = model.RealEstateAddress;
                entity.RealEstateCity    = model.RealEstateCity;
                entity.RealEstateState   = model.RealEstateState;
                entity.RealEstateZip     = model.RealEstateZip;
                entity.PropertyType      = model.PropertyType;
                entity.HasBasement       = model.HasBasement;
                entity.HasPool           = model.HasPool;
                entity.Bedroom           = model.Bedroom;
                entity.Bathroom          = model.Bathroom;
                entity.Stories           = model.Stories;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Put(RealEstatePropertyUpdate realEstateProperty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateRealEstatePropertyService();

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

            return(Ok());
        }