public async Task <IActionResult> PutWorkObject(int id, PublicApi.v1.DTO.WorkObject workObject) { if (!await _bll.WorkObjects.BelongsToUserAsync(id, User.GetUserId())) { return(NotFound()); } _bll.WorkObjects.Update(PublicApi.v1.Mappers.WorkObjectMapper.MapFromExternal(workObject)); await _bll.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <PublicApi.v1.DTO.WorkObject> > PostWorkObject( PublicApi.v1.DTO.WorkObject workObject) { // if (!await _bll.WorkObjects.BelongsToUserAsync(workObject.Id, User.GetUserId())) // { // return NotFound(); // } workObject = PublicApi.v1.Mappers.WorkObjectMapper.MapFromInternal( _bll.WorkObjects.Add(PublicApi.v1.Mappers.WorkObjectMapper.MapFromExternal(workObject))); await _bll.SaveChangesAsync(); workObject = PublicApi.v1.Mappers.WorkObjectMapper.MapFromInternal( _bll.WorkObjects.GetUpdatesAfterUOWSaveChanges( PublicApi.v1.Mappers.WorkObjectMapper.MapFromExternal(workObject))); return(CreatedAtAction("GetWorkObject", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = workObject.Id }, workObject)); }