public TopBl(TopDto dto) { if (dto != null) { Id = dto.Id; Name = dto.Name; Comment = dto.Comment; } }
public TopDto Add(TopDto dto) { var item = new Top() { Name = dto.Name, Comment = dto.Comment, }; _dao.Create(item); return(_map(item)); }
public ActionResult <TopDto> Add([FromBody] TopDto dto) { try { var item = _bl.Add(dto); return(CreatedAtRoute("GetTopById", new { Id = item.Id }, item)); } catch (Exception ex) { return(Conflict(ex.Message)); } }
public TopDto Update(TopDto dto) { var item = _dao.Get(dto.Id); if (item == null) { throw new KeyNotFoundException(); } item.Name = dto.Name; item.Comment = dto.Comment; _dao.Update(item); return(_map(item)); }
public ActionResult <TopDto> Update([FromBody] TopDto dto) { try { return(_bl.Update(dto)); } catch (KeyNotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(Conflict(ex.Message)); } }
public TopDto Update(TopDto item) { return(Url.AppendPathSegment("Top") .PutJsonAsync(item).ReceiveJson <TopDto>().Result); }