Exemplo n.º 1
0
        public HttpResponseMessage DeleteCustomer(string CustomerOperateDTO)
        {
            CustomerOperateDTO dto          = TransformHelper.ConvertBase64JsonStringToDTO <CustomerOperateDTO>(CustomerOperateDTO);
            ResultDTO <object> actionresult = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _ICustomerServices.DeleteCustomer(dto);
            }
            catch (DbUpdateException ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = "此条信息已使用不可删除!";
            }
            catch (Exception ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = ex.Message;
            }

            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }
Exemplo n.º 2
0
        public ActionResult CustomerDelete(long id)
        {
            var shipments = shipmentServices.Count(x => x.CneeId == id || x.ShipperId == id);

            if (shipments > 0)
            {
                var value = new
                {
                    Views   = "This customer have shipment, you can not delete it",
                    Title   = "Error!",
                    IsRemve = false,
                    Success = false,
                    TdId    = "del_" + id
                };
                return(JsonResult(value, true));
            }

            if (customerServices.DeleteCustomer(id))
            {
                var crmcus = crmService.FindEntity(x => x.SsmCusId == id);
                if (crmcus != null)
                {
                    crmService.SetMoveCustomerToData(crmcus.Id, false, id);
                }
            }
            var value2 = new
            {
                Views   = "Bạn đã xoá thành công",
                Title   = "Success!",
                IsRemve = true,
                TdId    = "del_" + id
            };

            return(JsonResult(value2, true));
        }
Exemplo n.º 3
0
 //Delete API/Customer/1
 public bool Delete(int id)
 {
     if (id > 0)
     {
         return(_customerServices.DeleteCustomer(id));
     }
     return(false);
 }
Exemplo n.º 4
0
 public async Task <IActionResult> Delete(int?id)
 {
     if (await _customerServices.DeleteCustomer(id))
     {
         TempData["succcessMessage"] = _resourcesServices.GetLocalizedHtmlString("customer_msg_DeleteCustomerSuccess").ToString();
         return(RedirectToAction("Index"));
     }
     ViewData["errorMessage"] = _resourcesServices.GetLocalizedHtmlString("customer_msg_DeleteCustomerError");
     return(View("Index"));
 }
        public IActionResult Delete(int customerID)
        {
            var Result = _customerServices.DeleteCustomer(customerID);

            if (Result.Result.Data != null)
            {
                return(Ok(Result.Result.Data));
            }
            return(BadRequest(Result));
        }
 public IActionResult DeleteCustomer(Customer customer)
 {
     try
     {
         customerServices.DeleteCustomer(customer);
         return(Ok());
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 7
0
        public ActionResult Delete(string id)
        {
            // Validation.
            if ((id == null) ||
                (id.Trim() == string.Empty))
            {
                return(BadRequest());
            }

            // Object Flow Validation.
            CustomerItem customerItem = _iCustomerServices.GetCustomer(id).Result;

            if (customerItem == null)
            {
                return(NotFound());
            }
            bool isObjectFlowValid = _iFlowValid.IsValidOperation(BaseValidatorType.Delete, customerItem, null);

            if (!isObjectFlowValid)
            {
                return(BadRequest());
            }

            // Delete.
            MongoDB.Driver.DeleteResult clsDeleteResult = _iCustomerServices.DeleteCustomer(id).Result;

            // Return with case.
            if ((clsDeleteResult != null) &&
                (clsDeleteResult.IsAcknowledged) &&
                (clsDeleteResult.DeletedCount > 0))
            {
                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 8
0
 public IActionResult CustomerDelete(int id)
 {
     customerServices.DeleteCustomer(id);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 9
0
 public ActionResult DeleteConfirmed(int id)
 {
     service.DeleteCustomer(id);
     return(RedirectToAction("Index"));
 }