Example #1
0
        // Gets VIEW to edit single MoneyFlow
        public ActionResult Edit(int ID)
        {
            var service = CreateMoneyFlowService();
            var detail  = service.GetMoneyFlowByID(ID);
            var model   =
                new MoneyFlowEdit
            {
                MoneyFlowID = detail.MoneyFlowID,
                Revenue     = detail.Revenue,
                Expenses    = detail.Expenses,
                TaxesSum    = detail.TaxesSum,
                Profit      = detail.Profit,
            };

            return(View(model));
        }
Example #2
0
        public bool UpdateMoneyFlow(MoneyFlowEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .MoneyFlow
                    .Single(e => e.MoneyFlowID == model.MoneyFlowID && e.OwnerID == _userID);

                entity.Revenue  = model.Revenue;
                entity.Expenses = model.Expenses;
                entity.TaxesSum = model.TaxesSum;
                entity.Profit   = model.Profit;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #3
0
        public ActionResult Edit(int ID, MoneyFlowEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MoneyFlowID != ID)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateMoneyFlowService();

            if (service.UpdateMoneyFlow(model))
            {
                TempData["SaveResult"] = "Your MoneyFlow was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your MoneyFlow could not be updated.");
            return(View(model));
        }