public IActionResult Remove([FromRoute] string Id)
        {
            RemoveCustomerViewModel removeViewModel = new RemoveCustomerViewModel()
            {
                Id = Id
            };

            return(PartialView("_RemoveCustomerPartial", removeViewModel));
        }
Exemple #2
0
        public async Task <IActionResult> DeleteCustomer([FromBody] RemoveCustomerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { IsSuccessStatusCode = false, Errors = ModelState }));
            }
            var commandResult = await _customerService.Remove(model);

            return(commandResult ? Ok(new { IsSuccessStatusCode = true }) : (IActionResult)BadRequest(new { IsSuccessStatusCode = false, Errors = ModelState }));
        }
        public IActionResult Remove(RemoveCustomerViewModel removeData)
        {
            try
            {
                customerService.RemoveCustomerById(removeData.Id);
            }
            catch (CustomerNotFoundException notFound)
            {
                logger.LogError("Failed to find the customer entity {@Exception}", notFound.Message);
                logger.LogDebug("Failed to find the customer entity {@ExceptionMessage}", notFound);
            }
            catch (Exception e)
            {
                logger.LogError("Failed to remove the customer entity {@Exception}", e.Message);
                logger.LogDebug("Failed to remove customer entity {@ExceptionMessage}", e);
            }

            return(PartialView("_RemoveCustomerPartial", removeData));
        }
Exemple #4
0
        public IActionResult DeleteCustomer([FromBody] RemoveCustomerViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(new { IsSuccessStatusCode = false, Errors = ModelState }));
                }

                _customerService.Remove(model);

                if (Errors.Any())
                {
                    return(BadRequest(new { IsSuccessStatusCode = false, Errors }));
                }
                return(Ok(new { IsSuccessStatusCode = true }));
            }
            catch (Exception ex)
            {
                return(NotFound(new { IsSuccessStatusCode = false, Errors = ex.Message }));
            }
        }
Exemple #5
0
        /// <summary>
        /// Removes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        public async Task <bool> Remove(RemoveCustomerViewModel model)
        {
            var removeCustomerCommand = _mapper.Map <RemoveCustomerCommand>(model);

            return(await _commandDispatcher.Send(removeCustomerCommand));
        }
Exemple #6
0
        // GET: /<controller>/
        public IActionResult Remove()
        {
            RemoveCustomerViewModel removeCustomerViewModel = new RemoveCustomerViewModel(context.Customers.ToList());

            return(View(removeCustomerViewModel));
        }
        /// <summary>
        /// Removes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        public void Remove(RemoveCustomerViewModel model)
        {
            var removeCustomerCommand = _mapper.Map <RemoveCustomerCommand>(model);

            _commandDispatcher.Send(removeCustomerCommand);
        }