public HttpResponseMessage Put(int id, [FromBody] SenderViewModel model) { if (ModelState.IsValid) { var sender = new Sender() { SenderId = model.SenderId, ForName1 = model.ForName1, ForName2 = model.ForName2, AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, AddressLine3 = model.AddressLine3, Country = model.Country, Email = model.Email, Mobile = model.Mobile, HMRCPassword = model.HMRCPassword, HMRCUserId = model.HMRCUserId, Postcode = model.Postcode, SenderPassword = model.SenderPassword, SurName = model.SurName, Telephone = model.Telephone, Title = model.Title, Type = model.Type }; bool status = _senderService.Update(sender); if (status) { return(new HttpResponseMessage(HttpStatusCode.OK)); } throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); }
public virtual ActionResult Edit(long id, SenderModel model) { try { if (ModelState.IsValid) { _senders.Update(id, model); return(RedirectToAction(MVC.Sender.Edit(id))); } } catch (DublicateLoginException) { ModelState.AddModelError("Authentication.Login", Validation.LoginExists); } BindBag(); return(View()); }