Esempio n. 1
0
        public JsonResult UpdateProfile(string profile_id, string full_name, string mobile, string email, string address, string physical_id)
        {
            try
            {
                dynamic profile_info = Helper.DataHelper.Get("profile", Query.EQ("_id", long.Parse(profile_id)));
                profile_info.full_name = full_name;
                profile_info.mobile = mobile;
                profile_info.email = email;
                profile_info.address = address;
                profile_info.personal_id = physical_id;
                Helper.DataHelper.Save("profile", profile_info);

                CMSDBDataContext db = new CMSDBDataContext();
                Card card = (from e in db.Cards where e.CustomerCIF.Equals(profile_id) select e).SingleOrDefault();
                card.CardOwnerName = full_name;
                db.SubmitChanges();

                return Json(new { error_code = "00", error_message = "Cập nhật thành công" }, JsonRequestBehavior.AllowGet);
            }
            catch { return Json(new { error_code = "96", error_message = "Cập nhật không thành công" }, JsonRequestBehavior.AllowGet); }
        }
Esempio n. 2
0
        public JsonResult CashIn(string card_id, string profile_id, long amount, string note)
        {
            dynamic balance = Helper.GetAccountInfo(card_id);
            dynamic result = Helper.CashIn(profile_id, amount);
            CardActionLog log = new CardActionLog();
            log.ActionAt = "backend";
            log.ActionBy = User.Identity.Name;
            log.ActionCode = "CASHIN";
            log.ActionTime = DateTime.Now;
            log.Amount = amount;
            log.CardId = profile_id;
            log.StartBalance = balance.available_balance;
            log.Note = note;

            if (result.error_code.ToString() == "00")
            {
                balance = Helper.GetAccountInfo(card_id);
                log.EndBalance = balance.available_balance;
                CMSDBDataContext db = new CMSDBDataContext();
                Card card = (from c in db.Cards where c.CustomerCIF.Equals(card_id) select c).Single();
                card.Balance = decimal.Parse("0" + log.EndBalance.ToString());
                db.CardActionLogs.InsertOnSubmit(log);
                db.SubmitChanges();
            }

            return Json(new { error_code = result.error_code, error_message = result.error_message }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 3
0
 public ActionResult ChangeLock(string card_id)
 {
     //var id = new ObjectId(_id);
     dynamic user = Helper.DataHelper.Get("users", Query.EQ("UserName", card_id));
     ViewBag.Action = (user.Status == "LOCKED") ? "Mở khóa" : "Khóa";
     user.Status = (user.Status == "LOCKED") ? "ACTIVED" : "LOCKED";
     CMSDBDataContext db = new CMSDBDataContext();
     var card = (from element in db.Cards where element.CardId.Equals(card_id) select element).SingleOrDefault();
     if (card != null)
     {
         card.IsLockout = (user.Status == "LOCKED") ? true : false;
         db.SubmitChanges();
         db.Dispose();
     }
     Helper.DataHelper.SaveUpdate("users", user);
     return View();
 }