public HttpResponseMessage Edit(User user) { var model = _contactBusiness.Edit(user); if (model.StatusCode.Equals("200")) { return(Request.CreateResponse(model.StatusCode, model)); } else { return(Request.CreateResponse(model.StatusCode, model)); } }
public virtual ActionResult Read(int id) { var msg = _contactBusiness.GetList().SingleOrDefault(m => m.Id == id); if (!msg.IsRead) { msg.IsRead = true; _contactBusiness.Edit(msg); } return(View(msg)); }
public async Task <IActionResult> PutContact([FromRoute] int id, [FromBody] Contact contact) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contact.Id) { return(BadRequest()); } await _ContactBusiness.Edit(id, contact); return(NoContent()); } catch (DbUpdateConcurrencyException) { if (!await _ContactBusiness.Exists(id)) { return(NotFound()); } else { throw; } } catch (DbUpdateException ex) when(ex.InnerException is MySqlException sqlException && sqlException.Number == 1062) { return(BadRequest(new { fullName = new List <string>() { "A contact with this name already exists." } })); } catch { return(StatusCode((int)HttpStatusCode.InternalServerError)); } }