예제 #1
0
        public async Task <object> Delete(string UID)
        {
            bool isValid = await _customersService.DeleteCustomer(UID);

            _notification.SetNotificationMessage(isValid, Title, UID);

            return(_notification);
        }
예제 #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));
        }
예제 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            await _customersService.DeleteCustomer(id);

            return(RedirectToPage("./Index"));
        }
예제 #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));
        }