public async Task <TicketForListDto> UpdateTicketAssignee(TicketForListDto ticket) { var dataJson = JsonSerializer.Serialize(ticket); var stringContent = new StringContent(dataJson, Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync($"{_rootUrl}/updateAssignee", stringContent); if (response.IsSuccessStatusCode) { var responseString = await response.Content.ReadAsStringAsync(); return(JsonSerializer.Deserialize <TicketForListDto>(responseString, defaultJsonSerializerOptions)); } else { throw new Exception($"Failed to Modify Ticket. {await response.Content.ReadAsStringAsync()}"); } }
public async Task <IActionResult> UpdateAssignee(TicketForListDto ticketForListDto) { var userId = HttpContext.GetUserId(); if (!await _organizations.UserInOrganization(userId, ticketForListDto.OrganizationId)) { return(BadRequest($"User with ID {userId} has no access to Ticket with ID {ticketForListDto.Id}")); } if (!await _repo.ExistById(ticketForListDto.Id)) { return(BadRequest($"Ticket with ID {ticketForListDto.Id} does not exist.")); } var ticket = await _repo.GetById(ticketForListDto.Id); ticket.AssigneeId = ticketForListDto.Assignee.Id; var ticketToReturn = await _repo.Modify(ticket); return(Ok(_mapper.Map <TicketForListDto>(ticket))); }