Пример #1
0
        public ActionResult DeleteConfirmed([Bind(Include = "Id,CompanyName,CompanyId,CompanyDescription,ManagerName,Country,Address,PhoneNumber,EmailAddress,SupportType,InitialDate")] int id)
        {
            Customer customer = customerRepo.GetCustomerByID(id);

            customerRepo.DeleteCustomer(id);
            customerRepo.Save();
            return(Json(new { success = true }));
        }
Пример #2
0
        public IActionResult Delete(int id)
        {
            var result = repository.DeleteCustomer(id);

            if (!result)
            {
                return(NotFound());
            }

            return(NoContent());
        }
Пример #3
0
        public IActionResult Delete(int id)
        {
            var customer = _repo.GetCustomer(id);

            if (customer == null)
            {
                return(NotFound());
            }
            _repo.DeleteCustomer(id);
            return(View("Index"));
        }
        public IActionResult DeleteCustomer(int id)
        {
            if (!_repo.DeleteCustomer(id))
            {
                return(new NotFoundObjectResult(new { success = false, message = "Customer not found.", id }));
            }

            return(new OkObjectResult(new { success = true, id, message = "Customer deleted." })
            {
                StatusCode = 201
            });
        }
Пример #5
0
        public async Task <ActionResult> DeleteCustomer(string id)
        {
            try
            {
                await customerRepository.DeleteCustomer(id);

                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from database"));
            }
        }
        public override async Task <DeleteCustomerResponse> DeleteCustomer(DeleteCustomerRequest request,
                                                                           ServerCallContext context)
        {
            if (await repository.DeleteCustomer(Guid.Parse(request.Id)))
            {
                return(new DeleteCustomerResponse {
                    Id = request.Id, Result = "SUCCESS"
                });
            }

            return(new DeleteCustomerResponse {
                Id = string.Empty, Result = "FAILURE"
            });
        }
Пример #7
0
        public async Task <IActionResult> DeleteCustomer(string customerId)
        {
            var customerEntity = await _customersRepository.GetCustomer(customerId);

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

            _customersRepository.DeleteCustomer(customerEntity);
            await _customersRepository.SaveChanges();

            return(NoContent());
        }
Пример #8
0
        public async Task <ActionResult <Customers> > DeleteCustomer(string email)
        {
            try
            {
                var customerToDelete = await customersRepository.GetCustomer(email);

                if (customerToDelete == null)
                {
                    return(NotFound($"Custmer with email = {email} cannot be found"));
                }

                return(await customersRepository.DeleteCustomer(email));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error deleting customer"));
            }
        }
 // DELETE api/Customers/{id}
 public void Delete(int id)
 {
     _db.DeleteCustomer(id);
 }
Пример #10
0
        public async Task <IHttpActionResult> DeleteCustomer(Guid id)
        {
            var result = await repository.DeleteCustomer(id);

            return(Ok(result));
        }
Пример #11
0
        public ActionResult Delete(int id)
        {
            _service.DeleteCustomer(id);

            return(RedirectToAction(nameof(Index)));
        }