Ejemplo n.º 1
0
        public async Task <object> Delete(string UID)
        {
            bool isValid = await _customersService.DeleteCustomer(UID);

            _notification.SetNotificationMessage(isValid, Title, UID);

            return(_notification);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <CustomerAPIModel> > DeleteCustomer(string id)
        {
            var customerToBeDeleted = await _customersService.GetCustomerById(id);

            var customerAPIModel = _mapper.Map <Customers, CustomerAPIModel>(customerToBeDeleted);

            await _customersService.DeleteCustomer(customerToBeDeleted);

            return(Ok(customerAPIModel));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            await _customersService.DeleteCustomer(id);

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                await _customersService.DeleteCustomer(id);

                return(Ok("Customer record deleted successfully"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public ActionResult Delete(string id)
        {
            var result = _service.DeleteCustomer(id);

            if (result.Status == eOperationStatus.Success)
            {
                return(Ok(new { Success = result.Data }));
            }
            if (result.Status == eOperationStatus.NotFound)
            {
                return(NotFound());
            }
            return(BadRequest(new { Message = result.ExceptionMessage }));
        }
        public async Task <Customer> DeleteCustomer(int id)
        {
            try
            {
                Customer _customer = await _customersService.DeleteCustomer(id);

                return(_customer);
            }
            catch (Exception ex)
            {
                throw new QueryException(
                          ErrorBuilder.New()
                          .SetMessage(ex.Message)
                          .SetCode("DELETE_ERROR")
                          .Build());
            }
        }
        public async Task <IResult <bool> > DeleteCustomer(Guid id)
        {
            var customer = await _service.GetCustomer(id);

            if (customer == null)
            {
                return(await Result <bool> .FailAsync("customer not found"));
            }

            var removed = await _service.DeleteCustomer(customer);

            if (!removed)
            {
                return(await Result <bool> .FailAsync("unable to delete customer"));
            }

            return(await Result <bool> .SuccessAsync(removed));
        }