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