예제 #1
0
        public IActionResult AddMoney([FromBody] AddMoneyModel model)
        {
            var user = _userService.GetById(model.UserId);

            _userService.AddMoney(user, model.Money);

            return(Ok());
        }
예제 #2
0
        //加薪申请
        public int AddMoney(AddMoneyModel model)
        {
            string    ss = $"select uid from Userinfo where Uname ='{model.Uname}'";
            DataTable tb = DBHelper.GetDataTable(ss);

            string sql = $"insert into AddMoney values('{model.RoleName}','{model.AddMoneys}','{model.Remark}',{tb.Rows[0][0]})";

            return(DBHelper.ExecuteNonQuery(sql));
        }
예제 #3
0
        public ActionResult AddMoney(AddMoneyModel model)
        {
            double amount = 0;
            double.TryParse(model.Amount.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out amount);
            if (amount <= 0)
                throw new Exception("Invalid amount");

            return RedirectToAction("Pay", "Paypal", new { amount = amount });
        }
예제 #4
0
        internal bool VerifyAmount(AddMoneyModel model)
        {
            var member = context.Members.Single(x => x.MemberID == model.MemberID);

            if ((member.Points * decimal.Parse(ConfigurationManager.AppSettings["PointValue"])) < (member.AmountGiven.GetValueOrDefault() + model.Amount))
            {
                throw new CustomException("Given amount can not be more than point value.");
            }
            return(true);
        }
예제 #5
0
        public ActionResult AddMoney(AddMoneyModel model)
        {
            if (!ModelState.IsValid)
                return View(new AddMoneyModel(_userService.GetAllUsers()));

            // ReSharper disable once PossibleInvalidOperationException
            var transaction = new ReloadRequest(model.Amount.Value, model.UserId, UserContext.User.Id);

            _transactionService.Reload(transaction);
            var tempData = new TempDataFacade(TempData);
            tempData.SuccessMessage = _userService.GetUser(model.UserId).Name + "'s account has been credited. The current balance is " +
                                      _userService.GetBalance(model.UserId).ToString("C");
            return RedirectToAction("AddMoney");
        }
예제 #6
0
 internal void AddMoney(AddMoneyModel model)
 {
     using (var trans = context.Database.BeginTransaction())
     {
         context.ApplyLock <Member>();
         context.ApplyLock <MemeberAmountHistory>();
         var memebr = context.Members.Single(x => x.MemberID == model.MemberID);
         memebr.AmountGiven = memebr.AmountGiven.GetValueOrDefault() + model.Amount;
         var now = DateTime.UtcNow;
         context.MemeberAmountHistory.Add(new MemeberAmountHistory {
             AmountGiven = model.Amount, Date = now, MemeberID = model.MemberID
         });
         context.Commit();
         trans.Commit();
     }
 }
예제 #7
0
        public ActionResult AddMoney(AddMoneyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(new AddMoneyModel(_userService.GetAllUsers())));
            }

            // ReSharper disable once PossibleInvalidOperationException
            var transaction = new ReloadRequest(model.Amount.Value, model.UserId, UserContext.User.Id);

            _transactionService.Reload(transaction);
            var tempData = new TempDataFacade(TempData);

            tempData.SuccessMessage = _userService.GetUser(model.UserId).Name + "'s account has been credited. The current balance is " +
                                      _userService.GetBalance(model.UserId).ToString("C");
            return(RedirectToAction("AddMoney"));
        }
예제 #8
0
 public ActionResult GiveMoney(AddMoneyModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             service.VerifyAmount(model);
             service.AddMoney(model);
             return(RedirectToAction("EditMember", new { memberID = model.MemberID }));
         }
         catch (CustomException ex)
         {
             ViewData.Model = service.GetGiveMoneyModel(model.MemberID);
             ModelState.AddModelError("Amount", ex.Message);
         }
     }
     return(View());
 }
예제 #9
0
        public ActionResult AddMoney(AddMoneyModel model, int id)
        {
            Card card = db.Cards.Find(id);

            if (model.UserTypePin == card.Pin)
            {
                Transaction tr = new Transaction();
                tr.OperationDate = DateTime.Now;
                tr.CardID        = id;
                tr.Sum           = model.Sum;
                tr.Decription    = model.Description;

                db.Transactions.Add(tr);
                db.SaveChanges();
                card.Balance = card.Transactions.Sum(p => p.Sum);
                return(RedirectToAction("Details", "Card", new { id = tr.CardID }));
            }
            return(View(model));
        }
예제 #10
0
 //申请加薪
 public int AddMoneys(AddMoneyModel model)
 {
     return(dal.AddMoney(model));
 }