public dynamic GetProfile(string card_track)
        {
            card_track = card_track.Replace("%", "").Replace("?", "");
            card_track = Regex.Replace(card_track, "[^0-9A-Za-z]+", "");
            try
            {
                CMSDBDataContext db2   = new CMSDBDataContext();
                CardTrace        trace = new CardTrace();
                trace.CardTrace1       = card_track;
                trace.CustomerFullName = "TELLER 01";
                trace.CardNumber       = "1234679";
                db2.CardTraces.InsertOnSubmit(trace);
                db2.SubmitChanges();
            }
            catch { }
            var user = (from e in db.Users where e.CardID.Equals(card_track) select e).SingleOrDefault();

            if (user == null)
            {
                //card_track = "00187";
                //user = (from e in db.Users where e.CardID.Equals(card_track) select e).SingleOrDefault();
                return(null);
            }
            var profile_info = new { Id = user.UserId, FullName = user.FullName, Counter = "Counter 1", CardId = card_track };

            return(profile_info);
        }
Beispiel #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));
        }
        public dynamic[] GetLogActions(string card_id, int last_number)
        {
            try
            {
                CMSDBDataContext db = new CMSDBDataContext();
                var list            = (from e in db.CardActionLogs
                                       orderby e.ActionTime descending
                                       select(new
                {
                    ActionTime = e.ActionTime,
                    ActionCode = e.ActionCode,
                    ActionBy = e.ActionBy,
                    Note = e.Note,
                    CardId = e.CardId,
                    CardNumber = e.Card.CardNumber,
                    StartBalance = e.StartBalance,
                    EndBalance = e.EndBalance,
                    Amount = e.Amount
                })).Take(last_number).ToArray();

                return(list);
            }
            catch
            {
                return(null);
            }
        }
 public eWalletController()
 {
     if (db == null)
     {
         db = new CMSDBDataContext();
     }
 }
 public string GetLogAction(string card_id, string start_balance, string end_balance, string reference_id, string amount, string action_code, string action_by, string action_at, string note)
 {
     try
     {
         using (CMSDBDataContext db = new CMSDBDataContext())
         {
             CardActionLog log = new CardActionLog();
             log.ActionBy     = action_by;
             log.ActionCode   = action_code;
             log.ActionTime   = DateTime.Now;
             log.CardId       = card_id;
             log.Note         = note;
             log.ActionAt     = action_at;
             log.StartBalance = long.Parse("0" + start_balance);
             log.EndBalance   = long.Parse("0" + end_balance);
             log.Amount       = long.Parse("0" + amount);
             log.ReferenceID  = reference_id;
             db.CardActionLogs.InsertOnSubmit(log);
             try {
                 Card card = (from c in db.Cards where c.CardId.Equals(card_id) select c).Single();
                 card.Balance = decimal.Parse("0" + end_balance);
             }
             catch { }
             db.SubmitChanges();
             return("OK");
         }
     }
     catch
     {
         return(String.Empty);
     }
 }
Beispiel #6
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());
        }
 public string GetActive(string card_id, string full_name, string customer_cif)
 {
     using (CMSDBDataContext db = new CMSDBDataContext())
     {
         var card_info = (from e in db.Cards where e.CardId.Equals(card_id) select e).Single();
         if (card_info == null)
         {
             return(String.Empty);
         }
         card_info.CardOwnerName = full_name;
         card_info.CustomerCIF   = customer_cif;
         card_info.ActivedDate   = DateTime.Now;
         card_info.Valid         = card_info.ActivedDate;
         card_info.Expire        = ((DateTime)card_info.ActivedDate).AddMonths(6);
         card_info.IsActived     = true;
         db.SubmitChanges();
         return("OK");
     }
 }
Beispiel #8
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)); }
        }
        public string GetUpdateProfile(string profile_id, string full_name, string mobile, string email, string address, string physical_id, int Pin)
        {
            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("OK");
            }
            catch { return(String.Empty); }
        }