コード例 #1
0
        public static RechargeAccountViewModel Create(RechargeAccount rechargeAccount = null)
        {
            var viewModel = new RechargeAccountViewModel()
            {
                RechargeAccount = rechargeAccount ?? new RechargeAccount()
            };

            return(viewModel);
        }
コード例 #2
0
        public ActionResult CreateRechargeAccount(RechargeAccount rechargeAccount)
        {
            rechargeAccount.User = GetCurrentUser(true);
            ModelState.Clear();
            rechargeAccount.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _repositoryFactory.RechargeAccountRepository.EnsurePersistent(rechargeAccount);
                Message = "Recharge Account has been saved.";
                return(RedirectToAction("RechargeAccounts"));
            }

            return(View(RechargeAccountViewModel.Create(rechargeAccount)));
        }
コード例 #3
0
ファイル: PIController.cs プロジェクト: ucdavis/CAESGenome
        public ActionResult CreateRechargeAccount(RechargeAccount rechargeAccount)
        {
            rechargeAccount.User = GetCurrentUser(true);
            ModelState.Clear();
            rechargeAccount.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _repositoryFactory.RechargeAccountRepository.EnsurePersistent(rechargeAccount);
                Message = "Recharge Account has been saved.";
                return RedirectToAction("RechargeAccounts");
            }

            return View(RechargeAccountViewModel.Create(rechargeAccount));
        }
コード例 #4
0
        public ActionResult EditRechargeAccount(int id, RechargeAccount rechargeAccount)
        {
            var rechargeAccountToEdit = _repositoryFactory.RechargeAccountRepository.GetNullableById(id);

            if (rechargeAccountToEdit == null)
            {
                Message = "Recharge account could not be found.";
                return(RedirectToAction("RechargeAccounts"));
            }

            AutoMapper.Mapper.Map(rechargeAccount, rechargeAccountToEdit);
            ModelState.Clear();
            rechargeAccountToEdit.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _repositoryFactory.RechargeAccountRepository.EnsurePersistent(rechargeAccountToEdit);
                Message = "Recharge Account has been saved.";
                return(RedirectToAction("RechargeAccounts"));
            }

            return(View(RechargeAccountViewModel.Create(rechargeAccountToEdit)));
        }
コード例 #5
0
ファイル: PIController.cs プロジェクト: ucdavis/CAESGenome
        public ActionResult EditRechargeAccount(int id, RechargeAccount rechargeAccount)
        {
            var rechargeAccountToEdit = _repositoryFactory.RechargeAccountRepository.GetNullableById(id);

            if (rechargeAccountToEdit == null)
            {
                Message = "Recharge account could not be found.";
                return RedirectToAction("RechargeAccounts");
            }

            AutoMapper.Mapper.Map(rechargeAccount, rechargeAccountToEdit);
            ModelState.Clear();
            rechargeAccountToEdit.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _repositoryFactory.RechargeAccountRepository.EnsurePersistent(rechargeAccountToEdit);
                Message = "Recharge Account has been saved.";
                return RedirectToAction("RechargeAccounts");
            }

            return View(RechargeAccountViewModel.Create(rechargeAccountToEdit));
        }