예제 #1
0
        public ActionResult Update(string key, string json)
        {
            var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công.");

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                var model    = _da.GetById(ItemId);
                var birth    = Request["Birthday_"];
                var serial   = Request["CardSerial"];
                var pin      = Request["PinCard"];
                var NoteCate = Request["NoteCate"];
                var PassWord = Request["PassWord"];
                model.Birthday = birth.StringToDecimal();
                var phone = model.Phone;
                UpdateModel(model);
                if (!model.CardID.HasValue && !string.IsNullOrEmpty(serial))
                {
                    var carditem = _da.GetCardItem(serial, pin);
                    if (carditem != null)
                    {
                        model.CardID = carditem.ID;
                    }
                }
                var customerCare = model.Customer_Care.FirstOrDefault();
                if (customerCare != null && !string.IsNullOrEmpty(NoteCate))
                {
                    customerCare.Note = HttpUtility.UrlDecode(NoteCate);
                }
                else if (!string.IsNullOrEmpty(NoteCate))
                {
                    customerCare = new Customer_Care
                    {
                        Note     = HttpUtility.UrlDecode(NoteCate),
                        AgencyId = Agencyid()
                    };
                    model.Customer_Care.Add(customerCare);
                }
                if (!string.IsNullOrEmpty(PassWord))
                {
                    model.PassWord = FDIUtils.CreatePasswordHash(PassWord, model.PasswordSalt);
                }
                model.FullName = HttpUtility.UrlDecode(model.FullName);
                model.Address  = HttpUtility.UrlDecode(model.Address);
                model.Phone    = phone;
                _da.Save();
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được cập nhật";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
 public ActionResult UpdateCusPass(string key, string code, string passold, string passnew)
 {
     try
     {
         if (key == Keyapi)
         {
             var userlogin = _dalogin.GetCustomerByCode(code);
             if (userlogin != null)
             {
                 var user = _customerDa.GetById(userlogin.ID);
                 if (user != null && FDIUtils.CreatePasswordHash(passold, user.PasswordSalt) == user.PassWord)
                 {
                     user.PassWord = FDIUtils.CreatePasswordHash(passnew, user.PasswordSalt);
                     _customerDa.Save();
                 }
                 else
                 {
                     return(Json(2, JsonRequestBehavior.AllowGet));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
     return(Json(1, JsonRequestBehavior.AllowGet));
 }
예제 #3
0
        public void UpdateLevelCustomer(int customerId)
        {
            var config = _walletCustomerDa.GetConfig();
            var wallet = customerDA.GetById(customerId);

            if (wallet != null)
            {
                var total = wallet.CashOutWallets.Where(c => c.Type == 1).Sum(c => c.TotalPrice);
                if (total > 0)
                {
                    var point  = (decimal)total * (config.Point / config.Price);
                    var policy = _customerPolicyDa.GetItemByPrice(point ?? 0);
                    if (policy != null)
                    {
                        wallet.CustomerPolicyID = policy.ID;
                        customerDA.Save();
                    }
                }
            }
        }
예제 #4
0
 public CustomerDE GetCustomerById(int id)
 {
     return(_mCustomerDA.GetById(id));
 }
예제 #5
0
        public ActionResult Actions()
        {
            var model = new Customer();
            var msg   = new JsonMessage(false, "Thêm mới dữ liệu thành công.");

            //List<Customer> ltsCustomerItems;
            //StringBuilder stbMessage;
            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(model);
                    var birth    = Request["Birthday_"];
                    var parent   = Request["Parent"];
                    var serial   = Request["CardSerial"];
                    var pin      = Request["PinCard"];
                    var NoteCate = Request["NoteCate"];

                    if (!string.IsNullOrEmpty(serial))
                    {
                        var carditem = _da.GetCardItem(serial, pin);
                        model.CardID = carditem.ID;
                    }
                    model.Birthday     = ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(birth));
                    model.DateCreated  = ConvertDate.TotalSeconds(DateTime.Now);
                    model.IsDelete     = false;
                    model.IsActive     = true;
                    model.PasswordSalt = FDIUtils.CreateSaltKey(5);
                    model.PassWord     = FDIUtils.CreatePasswordHash(model.PassWord ?? "ssc123456", model.PasswordSalt);
                    if (!string.IsNullOrEmpty(NoteCate))
                    {
                        var customerCare = new Customer_Care
                        {
                            Note     = NoteCate,
                            AgencyId = AgencyId
                        };
                        model.Customer_Care.Add(customerCare);
                    }
                    _da.Add(model);
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Thêm mới thất bại.";
                }
                break;

            case ActionType.Edit:
                try
                {
                    model = _da.GetById(ArrId.FirstOrDefault());
                    var birth  = Request["Birthday_"];
                    var serial = Request["CardSerial"];
                    var pin    = Request["PinCard"];
                    model.Birthday = ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(birth));
                    var phone = model.Phone;
                    UpdateModel(model);
                    if (!model.CardID.HasValue && !string.IsNullOrEmpty(serial))
                    {
                        var carditem = _da.GetCardItem(serial, pin);
                        if (carditem != null)
                        {
                            model.CardID = carditem.ID;
                        }
                    }
                    if (!string.IsNullOrEmpty(model.PassWord))
                    {
                        model.PassWord = FDIUtils.CreatePasswordHash(model.PassWord, model.PasswordSalt);
                    }
                    model.Phone = phone;
                    _da.Save();
                    msg.Message = "Cập nhật dữ liệu thành công";
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật";
                    Log2File.LogExceptionToFile(ex);
                }
                break;

            case ActionType.Delete:
                try
                {
                    var lst = _da.GetListByArrId(ArrId);
                    foreach (var item in lst)
                    {
                        item.IsDelete = true;
                    }
                    _da.Save();
                    msg.Message = "Xóa dữ liệu thành công";
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được xóa";
                    Log2File.LogExceptionToFile(ex);
                }
                break;

            default:
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public ActionResult AjaxView()
        {
            var model = _customerDa.GetById(ArrId.FirstOrDefault());

            return(View(model));
        }