public async Task <ActionResult <V1DTO.ActionTypeDTO> > PostActionType(V1DTO.ActionTypeDTO actionTypeDTO) { // Create actionType var bllEntity = _mapper.Map(actionTypeDTO); _bll.ActionTypes.Add(bllEntity); await _bll.SaveChangesAsync(); actionTypeDTO.Id = bllEntity.Id; return(CreatedAtAction( "GetActionType", new { id = actionTypeDTO.Id, version = HttpContext.GetRequestedApiVersion()?.ToString() ?? "0" }, actionTypeDTO )); }
public async Task <IActionResult> PutActionType(Guid id, V1DTO.ActionTypeDTO actionTypeDTO) { // Don't allow wrong data if (id != actionTypeDTO.Id) { return(BadRequest(new V1DTO.MessageDTO("id and actionType.id do not match"))); } var actionType = await _bll.ActionTypes.FirstOrDefaultAsync(actionTypeDTO.Id, User.UserGuidId()); if (actionType == null) { _logger.LogError($"EDIT. No such actionType: {actionTypeDTO.Id}, user: {User.UserGuidId()}"); return(NotFound(new V1DTO.MessageDTO($"No ActionType found for id {id}"))); } // Update existing actionType await _bll.ActionTypes.UpdateAsync(_mapper.Map(actionTypeDTO), User.UserId()); await _bll.SaveChangesAsync(); return(NoContent()); }