public async Task <IActionResult> Delete([FromRoute] int customerId)
 {
     if (User != null && User.Claims != null)
     {
         getTokenDetails();
         if ((authId != null && await _customerRepository.MatchingAuthId(customerId, authId)) ||
             (clientId != null && clientId.Equals("customer_ordering_api")))
         {
             var customer = _mapper.Map <CustomerDto>(await _customerRepository.GetCustomer(customerId));
             if (customer != null &&
                 await AnonymiseCustomer(customerId))
             {
                 if (clientId != "customer_ordering_api")
                 {
                     if (!await _orderFacade.DeleteCustomer(customerId))
                     {
                         //write to local db to be reattempted later
                     }
                 }
                 if (!await _reviewFacade.DeleteCustomer(customerId))
                 {
                     //write to local db to be reattempted later
                 }
                 if (!await _authFacade.DeleteAccount(customer.CustomerAuthId))
                 {
                     //write to local db to be reattempted later
                 }
                 return(Ok());
             }
             return(NotFound());
         }
     }
     return(Forbid());
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete([FromRoute] int customerId)
        {
            var customer = await _customerRepository.GetCustomer(customerId);

            if (customer != null &&
                await AnonymiseCustomer(customerId))
            {
                if (!await _orderFacade.DeleteCustomer(customerId))
                {
                    //write to local db to be reattempted later
                }
                if (!await _reviewFacade.DeleteCustomer(customerId))
                {
                    //write to local db to be reattempted later
                }
                if (!await _authFacade.DeleteAccount(customer.CustomerAuthId))
                {
                    //write to local db to be reattempted later
                }
                return(Ok());
            }
            return(NotFound());
        }