public IHttpActionResult Put(int id, EntryDto entryDto) { if (!ModelState.IsValid) return BadRequest(ModelState); _entriesRepository.Update(entryDto.ToModel()); return StatusCode(System.Net.HttpStatusCode.NoContent); }
public IHttpActionResult Put(int id, EntryDto entry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _entriesRepository.Add(entry.ToModel()); return(StatusCode(System.Net.HttpStatusCode.NoContent)); }
public IHttpActionResult Put(int id, EntryDto entryDto) { ValidateEntry(entryDto); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entryModel = entryDto.ToModel(); _entriesRepository.Update(entryModel); return(StatusCode(System.Net.HttpStatusCode.NoContent)); }
public IHttpActionResult Post(EntryDto entry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entryModel = entry.ToModel(); _entriesRepository.Add(entryModel); return(Created( Url.Link("DefaultApi", new { controller = "Entries", id = entry.Id }), entry)); }
public IHttpActionResult Post(EntryDto entryDto) { if (!ModelState.IsValid) return BadRequest(ModelState); var entry = entryDto.ToModel(); _entriesRepository.Add(entry); entryDto.Id = entry.Id; return Created( Url.Link(WebApiConfig.DefaultApiName, new { controller = "Entries", id = entryDto.Id }), entryDto); }