Ejemplo n.º 1
0
        public ActionResult Charge(ChargeViewModel chargeViewModel)
        {
            Debug.WriteLine(chargeViewModel.StripeEmail);
            Debug.WriteLine(chargeViewModel.StripeToken);

            return(RedirectToAction("Confirmation"));
        }
Ejemplo n.º 2
0
        public static ChargeViewModel ToViewModelCharge(tbl_GLChargeMaster_BasicInfo charge, ICollection <tbl_GLChargeMaster_Details> ChargeTrnList)
        {
            var purchaseviewmodel = new ChargeViewModel
            {
                ChargeName    = charge.ChargeName,
                ReferenceDate = charge.ReferenceDate,
                Status        = charge.Status,
                ID            = charge.CID,
            };

            IList <ChargeDetailsViewModel> ChargeTrnViewModelList = new List <ChargeDetailsViewModel>();

            foreach (var c in ChargeTrnList)
            {
                var ChargeTrnViewModel = new ChargeDetailsViewModel
                {
                    ID = c.ID,
                    LoanAmountGreaterthan = c.LoanAmtFrom,
                    LoanAmountLessthan    = c.LoanAmtTo,
                    ChargeAmount          = c.Charges,
                    ChargeType            = c.ChargeType,
                };
                ChargeTrnViewModelList.Add(ChargeTrnViewModel);
            }
            purchaseviewmodel.chargeDetailsCollection = ChargeTrnViewModelList;
            return(purchaseviewmodel);
        }
Ejemplo n.º 3
0
        public void SaveRecord(ChargeViewModel chargeViewModel)
        {
            tbl_GLChargeMaster_BasicInfo tblCharge        = new tbl_GLChargeMaster_BasicInfo();
            tbl_GLChargeMaster_Details   tblChargeDetails = new tbl_GLChargeMaster_Details();

            tblCharge.ChargeName    = chargeViewModel.ChargeName;
            tblCharge.ReferenceDate = chargeViewModel.ReferenceDate;
            tblCharge.Status        = chargeViewModel.Status;
            tblCharge.BranchID      = Convert.ToInt32(HttpContext.Current.Session["BranchId"]);
            tblCharge.CMPId         = Convert.ToInt32(HttpContext.Current.Session["CompanyId"]);
            tblCharge.FYID          = Convert.ToInt32(HttpContext.Current.Session["FinancialYearId"]);
            tblCharge.CreatedDate   = DateTime.Now;
            tblCharge.CreatedBy     = chargeViewModel.CreatedBy;
            tblCharge.UpdatedDate   = DateTime.Now;
            tblCharge.UpdatedBy     = chargeViewModel.UpdatedBy;
            _context.tbl_GLChargeMaster_BasicInfo.Add(tblCharge);
            _context.SaveChanges();

            int CID = _context.tbl_GLChargeMaster_BasicInfo.Max(x => x.CID);

            //save the data in Charge Details table
            foreach (var p in chargeViewModel.chargeDetailsCollection)
            {
                var chargetrn = new tbl_GLChargeMaster_Details
                {
                    CID         = CID,
                    LoanAmtFrom = p.LoanAmountGreaterthan,
                    LoanAmtTo   = p.LoanAmountLessthan,
                    Charges     = p.ChargeAmount,
                    ChargeType  = p.ChargeType,
                };
                _context.tbl_GLChargeMaster_Details.Add(chargetrn);
                _context.SaveChanges();
            }
        }
        public async Task <JsonResult> UpdateChargesForSchedule([DataSourceRequest] DataSourceRequest request,
                                                                ChargeViewModel model)
        {
            var chargeSchedule =
                await
                db.ChargeSchedules.Include(x => x.Charges)
                .SingleOrDefaultAsync(x => x.ChargeScheduleId == model.ChargeScheduleId);

            if (chargeSchedule != null)
            {
                var charge = chargeSchedule.Charges.FirstOrDefault(x => x.ChargeId == model.ChargeId);
                if (charge != null)
                {
                    charge.LastEditDate    = DateTime.Now;
                    charge.LastEditedBy    = User.Identity.Name;
                    charge.StartRange      = model.StartRange;
                    charge.EndRange        = model.EndRange;
                    charge.UnitPrice       = decimal.Parse(model.UnitPrice);
                    db.Entry(charge).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    ModelState.Clear();
                }
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 5
0
        public ActionResult Create(string stripeToken)
        {
            StripeConfiguration.ApiKey = "sk_test_OcuHnDZ8Z69w3ZW3SvlthPnU00iV4dVHyt";

            // Token is created using Checkout or Elements!
            // Get the payment token submitted by the form:
            var token = stripeToken; // Using ASP.NET MVC
            //could save this token to a client's db info

            var options = new ChargeCreateOptions
            {
                Amount = 999,
                //change amount to the charge on a job object, etc!
                Currency    = "usd",
                Description = "Example charge",
                Source      = token,
            };
            var    service = new ChargeService();
            Charge charge  = service.Create(options);

            var model = new ChargeViewModel();

            model.ChargeId = charge.Id;

            //could store this charge id on an invoice table for later reference and refunds

            return(View("OrderStatus", model));
        }
Ejemplo n.º 6
0
        public static ChargeViewModel ToViewModelPurchase(Mst_Charge charge, ICollection <Mst_ChargeDetails> ChargeTrnList)
        {
            var purchaseviewmodel = new ChargeViewModel
            {
                ChargeName    = charge.Chg_Name,
                ReferenceDate = charge.Chg_ReferenceDate,
                Status        = charge.Chg_Status,
                ID            = charge.Chg_Id,
            };

            IList <ChargeDetailsViewModel> ChargeTrnViewModelList = new List <ChargeDetailsViewModel>();

            foreach (var c in ChargeTrnList)
            {
                var ChargeTrnViewModel = new ChargeDetailsViewModel
                {
                    ID = c.Chgd_Id,
                    LoanAmountGreaterthan = c.Chgd_LoanAmountGreater,
                    LoanAmountLessthan    = c.Chgd_LoanAmountLess,
                    ChargeAmount          = c.Chgd_ChargesAmt,
                    ChargeType            = (short)c.Chgd_ChargeType,
                    ChargeTypeStr         = c.Chgd_ChargeType == 1 ? "Amount" : "Percentage"
                };
                ChargeTrnViewModelList.Add(ChargeTrnViewModel);
            }
            purchaseviewmodel.chargeDetailsCollection = ChargeTrnViewModelList;
            return(purchaseviewmodel);
        }
Ejemplo n.º 7
0
 public ActionResult Insert(ChargeViewModel objViewModel)
 {
     try
     {
         ModelState.Remove("Id");
         if (ModelState.IsValid)
         {
             if (objViewModel.ID == 0)
             {
                 if (InsertData(objViewModel))
                 {
                     return(Json(1, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     return(Json(3, JsonRequestBehavior.AllowGet));
                 }
             }
             else
             {
                 if (UpdateData(objViewModel))
                 {
                     return(Json(2, JsonRequestBehavior.AllowGet));
                 }
             }
         }
         objViewModel.chargeDetailsCollection = new List <ChargeDetailsViewModel>();
         return(View("Charge", objViewModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 8
0
        // GET: Charge
        public ActionResult Index()
        {
            var cvm = new ChargeViewModel();

            cvm.ChargesList = _chargeRepository.ListarCargos();
            return(View("~/Views/Charge/ChargeView.cshtml", cvm));
        }
Ejemplo n.º 9
0
        public ActionResult Create(string stripeToken, int id)
        {
            Book   bookid = context.Books.Single(b => b.ID == id);
            double amount = bookid.Price;

            StripeConfiguration.ApiKey = configuration["StripeApiKey"];
            var options = new ChargeCreateOptions
            {
                Amount      = (long)(amount * 100),
                Currency    = "usd",
                Description = "testing charge",
                Source      = stripeToken
            };
            var    service = new ChargeService();
            Charge charge  = service.Create(options);
            var    model   = new ChargeViewModel();

            model.ChargeId = charge.Id;
            model.Amount   = charge.Amount * 0.01;

            /*//StripeConfiguration.ApiKey = "sk_test_51GwAkHBHryiDErftLqW5lCWQuNzqUtUd6p3Z7mPP59kD0a0C6hMCCoGYb2Tjg21Y94Q8CgPryg6Sie8Xm0aD1w4e005ycdr6wj";
             *
             * var options = new TransferCreateOptions
             * {
             *  Amount = 400,
             *  Currency = "usd",
             *  Destination = "acct_1GwAkHBHryiDErft4573201",
             *  TransferGroup = "ORDER_95",
             * };
             * var service = new TransferService();
             * service.Create(options);*/


            return(View("OrderStatus", model));
        }
Ejemplo n.º 10
0
        public async Task Load_Single()
        {
            StubIExpenseRepository repository =
                new StubIExpenseRepository()
            {
                GetChargeAsyncInt32 =
                    (chargeId) =>
                {
                    return(Task.FromResult(
                               new Charge()
                    {
                        ChargeId = chargeId,
                    }));
                }
            };

            ServiceLocator.Current.SetService <IExpenseRepository>(repository);

            ChargeViewModel chargeViewModel = new ChargeViewModel();

            Assert.AreEqual(0, chargeViewModel.ChargeId);
            await chargeViewModel.LoadAsync(1);

            Assert.AreEqual(1, chargeViewModel.ChargeId);
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> Create([Bind(Include = "StartRange,EndRange,ChargeScheduleId,UnitPrice")] ChargeViewModel chargeVm)
        {
            var chargeSchedule = await db.ChargeSchedules.FindAsync(chargeVm.ChargeScheduleId);

            if (chargeSchedule != null)
            {
                try
                {
                    var charge = new Charge
                    {
                        DateCreated      = DateTime.Now,
                        StartRange       = chargeVm.StartRange,
                        EndRange         = chargeVm.EndRange,
                        CreatedBy        = User.Identity.Name,
                        ChargeId         = IdentityGenerator.NewSequentialGuid(),
                        ChargeScheduleId = chargeSchedule.ChargeScheduleId,
                        UnitPrice        = decimal.Parse(chargeVm.UnitPrice)
                    };
                    db.Charges.Add(charge);
                    await db.SaveChangesAsync();

                    TempData.Add("ChargeId", charge.ChargeId);
                    return(RedirectToAction("Index", "Charges"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("*", ex);
                    return(View(chargeVm));
                }
            }
            return(View(chargeVm));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Edit([Bind(Include = "ChargeId,StartRange,EndRange,ChargeScheduleId")] ChargeViewModel chargeVmModel)
        {
            var charge = await db.Charges.FindAsync(chargeVmModel.ChargeId);

            if (charge != null)
            {
                try
                {
                    charge.ChargeScheduleId = chargeVmModel.ChargeScheduleId;
                    charge.EndRange         = chargeVmModel.EndRange;
                    charge.StartRange       = chargeVmModel.StartRange;
                    charge.LastEditDate     = DateTime.Now;
                    charge.LastEditedBy     = User.Identity.Name;
                    db.Entry(charge).State  = EntityState.Modified;
                    await db.SaveChangesAsync();

                    TempData.Add("ChargeId", charge.ChargeId);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("*", ex);
                    return(View(chargeVmModel));
                }
            }
            ViewBag.ChargeScheduleId = new SelectList(db.ChargeSchedules, "ChargeScheduleId", "ChargeScheduleName",
                                                      charge.ChargeScheduleId);
            return(View(chargeVmModel));
        }
Ejemplo n.º 13
0
 public ActionResult UpdateCharge(ChargeViewModel chargeViewModel)
 {
     if (ModelState.IsValid)
     {
         // get existing charge
         BussinesLayer bl     = new BussinesLayer(new FinalDB());
         Charge        charge = bl.GetChargeByID(chargeViewModel.ID);
         charge.ManagerUserName  = Session["Username"] as string;
         charge.BudgetNumber     = chargeViewModel.BudgetNumber;
         charge.FundSource       = chargeViewModel.FundSource;
         charge.SignatureDate    = DateTime.Now;
         charge.ManagerSignature = chargeViewModel.ManagerSignature;
         // update charge
         bl.EditCharge(charge);
         // send message to student
         var memberController = DependencyResolver.Current.GetService <MemberController>();
         var sigTxt           = (chargeViewModel.ManagerSignature == true) ? "מאושרת" : "לא מאושרת";
         memberController.SendMessage(new Messages()
         {
             From    = Session["Username"] as string,
             ToUser  = charge.StudentUserName,
             Type    = MessageType.Charge,
             Subject = "Charge",
             Content = "סטטוס בקשה: " + sigTxt,
             Date    = DateTime.Now,
             IsSeen  = false
         });
         return(RedirectToAction("ShowNewCharges"));
     }
     else
     {
         this.SetErrorMsg("שדות לא תקינים");
         return(RedirectToAction("ShowNewCharges"));
     }
 }
 public ReceiptPage(ChargeViewModel vm)
 {
     _vm = vm;
     InitializeComponent();
     Receipt = vm.Receipt;
     CreateReceipt();
     BindingContext = vm;
 }
Ejemplo n.º 15
0
 public ActionResult SaveCharge(ChargeViewModel cvm)
 {
     if (cvm.Charge.Name != null)
     {
         _chargeRepository.SalvarCargo(
             cvm.Charge.Name);
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 16
0
        public void ShowCharge(ChargeViewModel chargeViewModel)
        {
            EventHandler <EventArgs <ChargeViewModel> > handler = this.ShowChargeRequested;

            if (handler != null)
            {
                handler(this, new EventArgs <ChargeViewModel>(chargeViewModel));
            }
        }
Ejemplo n.º 17
0
        public bool UpdateData(ChargeViewModel chargeViewModel)
        {
            bool retVal = false;

            chargeViewModel.CreatedBy = Convert.ToInt32(Session["UserLoginId"]);
            chargeViewModel.UpdatedBy = Convert.ToInt32(Session["UserLoginId"]);
            _chargeService.UpdateRecord(chargeViewModel);
            retVal = true;
            return(retVal);
        }
Ejemplo n.º 18
0
        public ChargeViewModel SetRecordinEdit(int ID)
        {
            ChargeViewModel chargeViewModel = new ChargeViewModel();
            var             chargeobj       = _context.tbl_GLChargeMaster_BasicInfo.Where(x => x.CID == ID).FirstOrDefault();
            //get charge trn table data
            var purchasetrndatalist = _context.tbl_GLChargeMaster_Details.Where(x => x.CID == ID).ToList();

            chargeViewModel = ToViewModelCharge(chargeobj, purchasetrndatalist);
            return(chargeViewModel);
        }
Ejemplo n.º 19
0
        void OnViewChargeRequested(object sender, EventArgs e)
        {
            DevExpress.Mvvm.IDialogService service = ViewChargeDialogService;
            ChargeViewModel chargeViewModel        = (ChargeViewModel)sender;

            List <UICommand> commands = new List <UICommand>();

            commands.Add(new UICommand(null, "Save and Close", chargeViewModel.SaveChargeCommand, true, false));
            commands.Add(new UICommand(null, "Cancel", null, false, true));

            service.ShowDialog(commands, "A New Charge", chargeViewModel);
        }
Ejemplo n.º 20
0
        public bool InsertData(ChargeViewModel chargeViewModel)
        {
            bool retVal = false;

            chargeViewModel.CreatedBy = Convert.ToInt32(Session["UserLoginId"]);
            chargeViewModel.UpdatedBy = Convert.ToInt32(Session["UserLoginId"]);
            Mst_Charge        tblCharge        = new Mst_Charge();
            Mst_ChargeDetails tblChargeDetails = new Mst_ChargeDetails();

            try
            {
                tblCharge.Chg_Name            = chargeViewModel.ChargeName;
                tblCharge.Chg_ReferenceDate   = chargeViewModel.ReferenceDate;
                tblCharge.Chg_Status          = chargeViewModel.Status;
                tblCharge.Chg_RecordCreated   = DateTime.Now;
                tblCharge.Chg_RecordCreatedBy = chargeViewModel.CreatedBy;
                tblCharge.Chg_RecordUpdated   = DateTime.Now;
                tblCharge.Chg_RecordUpdatedBy = chargeViewModel.UpdatedBy;
                dd._context.Mst_Charge.Add(tblCharge);
                dd._context.SaveChanges();

                int PID = dd._context.Mst_Charge.Max(x => x.Chg_Id);

                //save the data in Charge Details table
                foreach (var p in chargeViewModel.chargeDetailsCollection)
                {
                    var chargetrn = new Mst_ChargeDetails
                    {
                        Chgd_ChgRefId          = PID,
                        Chgd_LoanAmountGreater = p.LoanAmountGreaterthan,
                        Chgd_LoanAmountLess    = p.LoanAmountLessthan,
                        Chgd_ChargesAmt        = p.ChargeAmount,
                        Chgd_ChargeType        = p.ChargeType,
                        Chg_RecordCreatedBy    = Convert.ToInt32(Session["UserLoginId"]),
                        Chg_RecordCreated      = DateTime.Now,
                        Chg_RecordUpdatedBy    = Convert.ToInt32(Session["UserLoginId"]),
                        Chg_RecordUpdated      = DateTime.Now,
                    };
                    dd._context.Mst_ChargeDetails.Add(chargetrn);
                    dd._context.SaveChanges();
                }
                retVal = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retVal);
        }
Ejemplo n.º 21
0
        public ActionResult Charge(int id, int CreditNumber)
        {
            // Get the user
            var user = db.Users.Find(id);

            ChargeViewModel vm = new ChargeViewModel()
            {
                Username = user.FullName
            };

            // Get the CreditNumber
            var creditNumber = db.Credits.SingleOrDefault(c => c.CreditNumber == CreditNumber);

            // Credit not exist
            if (creditNumber == null)
            {
                vm.Message     = "There is no credit with this number";
                vm.MessageType = "Error";
                return(View(vm));
            }

            // Check if it is paid
            if (!creditNumber.IsAvaliable)
            {
                vm.Message     = "This is credit is already paid";
                vm.MessageType = "Warning";
                return(View(vm));
            }

            // Check if it is not expire
            if (creditNumber.ExpireDate < DateTime.Now)
            {
                vm.Message     = "This is credit is expired at " + creditNumber.ExpireDate;
                vm.MessageType = "Warning";
                return(View(vm));
            }

            // Credit available
            creditNumber.User         = user;
            creditNumber.ActivateDate = DateTime.Now;
            creditNumber.IsAvaliable  = false;

            // User
            user.Balance += creditNumber.Balance;

            // Update
            db.SaveChanges();
            return(RedirectToAction("Index", new { id = user.UserId }));
        }
        public IActionResult OnPost(ChargeViewModel chargeViewModel)
        {
            var paymentmodel = new ChargeViewModel
            {
                //MerchantRef = Guid.NewGuid().ToString(),
                StripeAmount     = (int)(payInfo.AmountToPay * 100),
                StripeEmail      = HttpContext.User.Identity.Name,
                StripeFirst_Name = payInfo.First_Name + " " + payInfo.Last_Name,
                Description      = "SmartMeter Subscriber Payment"
            };

            Debug.WriteLine(chargeViewModel.StripeEmail);
            Debug.WriteLine(chargeViewModel.StripeToken);
            return(RedirectToPage("/Subscribers/Confirmation", "OnGet"));
        }
Ejemplo n.º 23
0
        public IActionResult Charge([FromBody] ChargeViewModel model)
        {
            var basket = _basketManager.GetBasket();

            basket.Customer = _mapper.Map <Customer>(model.Order.Customer);
            var paymentResult = _orderService.ProcessPayment(basket, model.Token);

            if (paymentResult.IsSuccessful)
            {
                _basketManager.ClearBasket();

                return(Ok(paymentResult));
            }

            return(BadRequest(paymentResult));
        }
Ejemplo n.º 24
0
 public ActionResult Charge()
 {
     try
     {
         ButtonVisiblity("Index");
         var chargeviewmodel = new ChargeViewModel();
         var chargetrn       = new ChargeDetailsViewModel();
         chargeviewmodel.chargeDetailsCollection = new List <ChargeDetailsViewModel>();
         chargeviewmodel.ReferenceDate           = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy"));
         return(View(chargeviewmodel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 25
0
        public async Task TestMethod1()
        {
            ServiceLocator.Current.SetService <INavigationService>(
                new StubINavigationService());

            StubIViewService viewService =
                new StubIViewService()
            {
                ExecuteBusyActionAsyncFuncOfTask =
                    async(Func <Task> func) =>
                {
                    await func();
                }
            };

            ServiceLocator.Current.SetService <IViewService>(viewService);

            StubIExpenseRepository repository =
                new StubIExpenseRepository()
            {
                GetChargeAsyncInt32 =
                    (chargeId) =>
                {
                    return(Task.FromResult(
                               new Charge()
                    {
                        ChargeId = chargeId,
                    }));
                }
            };

            ServiceLocator.Current.SetService <IExpenseRepository>(repository);



            // Create a new ChargeViewModel.
            ChargeViewModel chargeViewModel = new ChargeViewModel();

            // Make sure it defaults to a ChargeId of 0.
            Assert.AreEqual(0, chargeViewModel.ChargeId);

            // Load the charge with the ChargeId of 1.
            await chargeViewModel.LoadAsync(1);

            // Confirm the ViewModel’s ChargeId is 1.
            Assert.AreEqual(1, chargeViewModel.ChargeId);
        }
Ejemplo n.º 26
0
        public List <ChargeViewModel> SetDataofModalList()
        {
            List <ChargeViewModel> list = new List <ChargeViewModel>();
            var model     = new ChargeViewModel();
            var tablelist = _context.tbl_GLChargeMaster_BasicInfo.ToList();

            foreach (var item in tablelist)
            {
                model               = new ChargeViewModel();
                model.ID            = item.CID;
                model.ChargeName    = item.ChargeName;
                model.ReferenceDate = item.ReferenceDate;
                model.Status        = item.Status;
                list.Add(model);
            }
            return(list);
        }
        public ActionResult Charge(ChargeViewModel chargeViewModel)
        {
            Debug.WriteLine(chargeViewModel.StripeEmail);
            Debug.WriteLine(chargeViewModel.StripeToken);

            var token = chargeViewModel.StripeToken; // Using ASP.NET MVC

            var charges = new StripeChargeService();
            var charge  = charges.Create(new StripeChargeCreateOptions
            {
                Amount      = 1000,
                Currency    = "usd",
                Description = "Example charge",
                SourceTokenOrExistingSourceId = token
            });

            return(RedirectToAction("Confirmation"));
        }
Ejemplo n.º 28
0
 public ActionResult GetChargeDetailsById(int ID)
 {
     try
     {
         ChargeViewModel chargeViewModel = new ChargeViewModel();
         string          operation       = Session["Operation"].ToString();
         //get installation and service table data
         var chargeobj = dd._context.Mst_Charge.Where(x => x.Chg_Id == ID).FirstOrDefault();
         //get charge trn table data
         var purchasetrndatalist = dd._context.Mst_ChargeDetails.Where(x => x.Chgd_ChgRefId == ID).ToList();
         chargeViewModel           = ToViewModelPurchase(chargeobj, purchasetrndatalist);
         chargeViewModel.operation = operation;
         return(View("Charge", chargeViewModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 29
0
        public ActionResult VisitorActionsPayment(string stripeToken, string SignUp, string Comment)
        {
            StripeConfiguration.SetApiKey("sk_test_mdDGBM56VRabusYFI96kpuGh00PrprigoK");

            var options = new ChargeCreateOptions
            {
                Amount      = 2500,
                Currency    = "usd",
                Description = "Charge for [email protected]",
                SourceId    = stripeToken // obtained with Stripe.js,
            };
            var    service = new ChargeService();
            Charge charge  = service.Create(options);
            var    model   = new ChargeViewModel();

            model.ChargeId = charge.Id;
            return(View("DonationConfirmation", model));
            //return View();
        }
Ejemplo n.º 30
0
        // GET: Users/Charge/1
        public ActionResult Charge(int id)
        {
            // Get user
            var user = db.Users.Find(id);

            if (user == null)
            {
                return(HttpNotFound());
            }

            ChargeViewModel vm = new ChargeViewModel();

            vm.Message     = "";
            vm.MessageType = "";

            vm.Username = user.FullName;

            return(View(vm));
        }
Ejemplo n.º 31
0
        public async Task Load_Single()
        {
            StubIExpenseRepository repository =
                new StubIExpenseRepository()
                {
                    GetChargeAsyncInt32 =
                        (chargeId) =>
                        {
                            return Task.FromResult(
                                new Charge()
                                {
                                    ChargeId = chargeId,
                                });
                        }
                };

            ServiceLocator.Current.SetService<IExpenseRepository>(repository);

            ChargeViewModel chargeViewModel = new ChargeViewModel();
            Assert.AreEqual(0, chargeViewModel.ChargeId);
            await chargeViewModel.LoadAsync(1);
            Assert.AreEqual(1, chargeViewModel.ChargeId);
        }