Beispiel #1
0
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            var cliente = await ObterClientePorId(id);

            if (cliente == null)
            {
                return(NotFound());
            }

            var planos = _planoRepository.ObterPlanosIdCliente(id);

            await _clienteRepository.Remover(_mapper.Map <Cliente>(cliente));

            foreach (var item in planos)
            {
                item.ClienteId = null;
                await _planoRepository.Atualizar(item);
            }

            return(RedirectToAction("Index"));
        }