예제 #1
0
        public IHttpActionResult Put(EstateEdit estate)  //update estate
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateEstateService();

            if (!service.UpdateEstate(estate))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
예제 #2
0
 // [Authorize(Roles = "Admin")]
 public bool UpdateEstate(EstateEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Estates
             .Single(e => e.EstateId == model.EstateId);
         entity.Name       = model.Name;
         entity.Address    = model.Address;
         entity.Price      = model.Price;
         entity.Status     = model.Status;
         entity.EstateType = model.EstateType;
         return(ctx.SaveChanges() == 1);
     }
 }