public async Task <IActionResult> AddMoneyUserAccount(AddMoneyViewModel model)
        {
            Account sender   = null;
            Account receiver = accountService.FindAccountById(model.Account.Id).Result;
            string  comment  = "Пополнение";
            decimal amount   = 0;

            if (!accountService.AmountTryParse(model.Amount, out amount))
            {
                ModelState.AddModelError("Amount", localizer["AmountFormatValidation"]);
            }
            else if (amount <= 0)
            {
                ModelState.AddModelError("Amount", localizer["AmountNotNull"]);
            }

            if (ModelState.IsValid)
            {
                InnerTransfer transfer = await
                                         transferService.CreateInnerTransfer(sender, receiver, amount, comment, null, null, null);

                transferService.AddTransfer(transfer);
                if (receiver.UserInfoId != null)
                {
                    return(RedirectToAction("UserAccounts", "Account", new { userId = receiver.UserInfo.User.Id }));
                }
                else if (receiver.CompanyId != null)
                {
                    return(RedirectToAction("Index", "Account", new { companyId = receiver.CompanyId }));
                }
            }
            model.Account = receiver;
            return(View(model));
        }
Beispiel #2
0
        public ActionResult GiveMoney(int id)
        {
            AddMoneyViewModel model = service.GetGiveMoneyModel(id);

            //model.Date = DateTime.UtcNow.Date;
            return(View(model));
        }
        public IActionResult AddMoney(AddMoneyViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var voe = _db.VolunteersOnEvent.Find(vm.VolunteerOnEventId);

            if (voe == null)
            {
                return(BadRequest(ErrorMessagesProvider.VolunteerOnEventErrors.VolunteerOnEventNotExists));
            }

            if (!voe.Event.CanModify())
            {
                return(BadRequest());
            }

            voe.AmountOfMoneyCollected = vm.CollectedMoney;

            _db.VolunteersOnEvent.Update(voe);
            _db.SaveChanges();

            return(RedirectToAction("PastEventDetails", new { eventId = voe.EventId }));
        }
        public IActionResult AddMoney(int volunteerOnEventId, double collectedMoney)
        {
            var voe = _db.VolunteersOnEvent
                      .Include(ve => ve.Volunteer)
                      .Include(ve => ve.Event)
                      .FirstOrDefault(ve => ve.VolunteerOnEventId == volunteerOnEventId);

            if (voe == null)
            {
                return(BadRequest(ErrorMessagesProvider.VolunteerOnEventErrors.VolunteerOnEventNotExists));
            }

            if (!voe.Event.CanModify())
            {
                return(BadRequest());
            }

            var vm = new AddMoneyViewModel
            {
                VolunteerOnEventId = voe.VolunteerOnEventId,
                EventId            = voe.EventId,
                VolunteerName      = voe.Volunteer.FullName,
                CollectedMoney     = collectedMoney,
                EventName          = voe.Event.Name
            };

            return(View(vm));
        }
        public IActionResult AddMoneyUserAccount(int accountId)
        {
            Account           account = accountService.FindAccountById(accountId).Result;
            AddMoneyViewModel model   = new AddMoneyViewModel {
                Account = account
            };

            return(View(model));
        }
Beispiel #6
0
        public async Task <IActionResult> AddMoney(AddMoneyViewModel addMoney)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var user   = await db.Users.FindAsync(userId);

            ViewData["Money"] = user;
            user.Money       += addMoney.Money;
            db.Users.Update(user);
            await db.SaveChangesAsync();

            return(RedirectToAction("BuyerLC", "home"));
        }
        public ActionResult AddMoneyToStudent(AddMoneyViewModel addMoneyViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddMoney"));
            }

            Account currentUser = (Account)Session[UserType.LoggedInUser.ToString()];

            currentUser.BankAccount.Deposit = ElearnerDataLayoutActions.AddMoneyToUser(currentUser.Id, addMoneyViewModel.Amount);

            return(View("Index"));
        }
        public ActionResult AddMoney([Bind(Include = "Name,Wallet,Input,RechargeCost")] AddMoneyViewModel userVM)
        {
            string userId = User.Identity.GetUserId();
            var    user   = db.Users.Find(userId);

            if (ModelState.IsValid)
            {
                user.Wallet         += userVM.Input;
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
            }

            if (userVM.RechargeCost != null && (double)userVM.Input >= (double)userVM.RechargeCost)
            {
                userVM.RechargeCost = null;
            }

            return(RedirectToAction("AddMoney"));
        }
 internal AddMoneyView()
 {
     InitializeComponent();
     DataContext = new AddMoneyViewModel();
 }