Esempio n. 1
0
        public JsonResult Delete(string id)
        {
            var obj = new tblCustomer();

            //Check tồn tại trong cardcustomer
            var existedInCard = _tblCardService.GetAllByCustomerId(id);

            if (existedInCard.Any())
            {
                var result1 = new MessageReport();
                result1.Message   = "Khách hàng đang sử dụng thẻ. Không thể xóa.";
                result1.isSuccess = false;
            }

            //Check tồn tại trong event
            //var existedInEvent = _PK_VehicleEventService.GetAllEventByCustomerId(id);
            //if (existedInEvent.Any())
            //{
            //    var result1 = new Result();
            //    result1.ErrorCode = 500;
            //    result1.Message = "Khách hàng đang tồn tại trong sự kiện. Không thể xóa.";
            //    result1.Success = false;
            //}

            var result = _tblCustomerService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.AccessControlCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }