public bool EditPartyItem(PartyItemEdit partyItemToEdit) { var entity = _db.PartyItems.Single(p => p.PartyItemId == partyItemToEdit.Id); entity.Name = partyItemToEdit.Name; entity.Price = partyItemToEdit.Price; return(_db.SaveChanges() == 1); }
public ActionResult Edit(PartyItemEdit partyItem) { if (ModelState.IsValid) { _userId = Guid.Parse(User.Identity.GetUserId()); _partyItemService = new PartyItemService(_userId); _partyItemService.EditPartyItem(partyItem); return(RedirectToAction("Index")); } return(View(partyItem)); }
public IHttpActionResult Put(PartyItemEdit partyItemToEdit) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePartyItemService(); if (!service.EditPartyItem(partyItemToEdit)) { return(InternalServerError()); } return(Ok()); }