public async Task <ActionResult <ItemBookedDTO> > PostItemBooked(ItemBookedDTO itemBookedDTO) { itemBookedDTO.AppUserId = User.UserGuidId(); var bllEntity = _mapper.Map(itemBookedDTO); _bll.ItemsBooked.Add(bllEntity); await _bll.SaveChangesAsync(); itemBookedDTO.Id = bllEntity.Id; return(CreatedAtAction("GetItemBooked", new { id = itemBookedDTO.Id, version = HttpContext.GetRequestedApiVersion()?.ToString() ?? "0" }, itemBookedDTO)); }
public async Task <IActionResult> PutItemBooked(Guid id, ItemBookedDTO itemBookedDTO) { if (id != itemBookedDTO.Id) { return(BadRequest(new MessageDTO("Id and itemBookedEditDTO.id do not match"))); } if (!await _bll.ItemsBooked.ExistsAsync(id, User.UserGuidId())) { return(NotFound(new MessageDTO($"Booked Item with this id {id} not found"))); } itemBookedDTO.AppUserId = User.UserGuidId(); await _bll.ItemsBooked.UpdateAsync(_mapper.Map(itemBookedDTO)); await _bll.SaveChangesAsync(); return(NoContent()); }