public async Task <IActionResult> GetClient(int id) { var client = await _repo.GetClient(id); var clientToReturn = _mapper.Map <ClientForDetailedDto>(client); return(Ok(clientToReturn)); }
public async Task <IActionResult> DeleteTechnition(int userId, int id) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var clientFromRepo = await _repo.GetClient(userId); //if(!user.Tic.Any(p => p.Id == id)) // r//eturn Unauthorized(); var technitionFromRepo = await _repo.GetTechnition(id); if (technitionFromRepo == null) { return(BadRequest("technition is empty")); } // var deleteParams = new DeletionParams(ticketFromRepo.Id); _repo.Delete(technitionFromRepo); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to delete ticket")); }
public async Task <IActionResult> GetOpenTickets(int userId, TicketsForDetailedDto ticketsForDetailedDto) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var clientFromRepo = await _repo.GetClient(userId); //if(!clientFromRepo.Tickets.Any(t => t.Id == id )) //return Unauthorized(); var ticketFromRepo = await _repo.GetOpenTicketsForClient(userId); var ticketToReturn = _mapper.Map <IEnumerable <TicketsForDetailedDto> >(ticketFromRepo); return(Ok(ticketToReturn)); }