Пример #1
0
        public IHttpActionResult Edit(int id, EditHouseholdBindingModel household)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var houseHold = _db.Households.Where(h => h.Id == id).FirstOrDefault();

            houseHold.Name = household.Name;

            _db.SaveChanges();

            return(Ok());
        }
Пример #2
0
        public IHttpActionResult Edit(EditHouseholdBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var houseHold = _db.Households.FirstOrDefault(p => p.Id == model.Id);

            if (houseHold == null)
            {
                return(NotFound());
            }

            var userId = User.Identity.GetUserId();
            var user   = _db.Users.FirstOrDefault(p => p.Id == userId);

            _db.SaveChanges();

            return(Ok("User has been removed from the household"));
        }