Exemplo n.º 1
0
        public async Task <IActionResult> DeleteClient(int userId)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var client = await _repo.GetClient(userId);

            // if(!client.Tickets.Any(p => p.Id == id))
            //  return Unauthorized();

            // var ClienttFromRepo = await _repo.Get(id);

            // var deleteParams = new DeletionParams(ticketFromRepo.Id);

            _repo.Delete(client);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete ticket"));
        }
Exemplo n.º 2
0
        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"));
        }