public async Task <IActionResult> PutBillLine(int id, PublicApi.v1.DTO.BillLine billLine) { if (id != billLine.Id) { return(BadRequest()); } if (!await _bll.BillLines.BelongsToUserAsync(id, User.GetUserId())) { return(NotFound()); } _bll.BillLines.Update(PublicApi.v1.Mappers.BillLineMapper.MapFromExternal(billLine)); await _bll.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <PublicApi.v1.DTO.BillLine> > PostBillLine( PublicApi.v1.DTO.BillLine billLine) { if (!await _bll.BillLines.BelongsToUserAsync(billLine.Id, User.GetUserId())) { return(NotFound()); } billLine = PublicApi.v1.Mappers.BillLineMapper.MapFromInternal( _bll.BillLines.Add(PublicApi.v1.Mappers.BillLineMapper.MapFromExternal(billLine))); await _bll.SaveChangesAsync(); billLine = PublicApi.v1.Mappers.BillLineMapper.MapFromInternal( _bll.BillLines.GetUpdatesAfterUOWSaveChanges( PublicApi.v1.Mappers.BillLineMapper.MapFromExternal(billLine))); return(CreatedAtAction("GetBillLine", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = billLine.Id }, billLine)); }