Exemplo n.º 1
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.º 2
0
        public void SetSatusCrm(CRMCustomer crm)
        {
            bool          isCancel   = false;
            CRMStatusCode code       = CRMStatusCode.Potential;
            DateTime      cancelDate = crm.DateCancel ?? crm.CreatedDate.Date;

            DateTime lastCancelDate = cancelDate.AddDays(days);

            if (crm.SsmCusId.HasValue)
            {
                var shipments = shipmentServices.Count(s => s.CneeId.Value == crm.SsmCusId.Value || s.ShipperId.Value == crm.SsmCusId.Value);
                if (shipments == 0)
                {
                    code = CRMStatusCode.Potential;
                }
                if (shipments >= 1)
                {
                    code = CRMStatusCode.Success;
                }
            }
            else
            {
                if (lastCancelDate < DateTime.Today)
                {
                    isCancel = true;
                    code     = CRMStatusCode.Client;
                }
            }

            var status = statusService.GetModel(code);

            if (crm.CRMStatus.Code == (byte)code)
            {
                return;
            }
            crmService.SetStatus(crm.Id, status.Id, code, isCancel);
        }