public ActionResult Create(Envelope envelope)
        {
            if (ModelState.IsValid)
            {
                Services.EnvelopeService.InsertEnvelope(envelope, User.Identity.Name);
                return RedirectToAction("Index");
            }

            return View(envelope);
        }
示例#2
0
        public void InsertEnvelope(Envelope envelope, string username)
        {
            envelope.BudgetID       = uow.UserRepository.GetByPK(username).BudgetID;
            envelope.CurrentBalance = envelope.StartingBalance;

            uow.EnvelopeRepository.Insert(envelope);
            uow.Save();
        }
示例#3
0
 public void DeleteEnvelope(Envelope envelope)
 {
     uow.EnvelopeRepository.Delete(envelope);
     uow.Save();
 }
示例#4
0
        public void UpdateEnvelope(Envelope envelope)
        {
            Envelope envelopeBeforeUpdate = uow.EnvelopeRepository.GetByPK(envelope.EnvelopeID);

            envelope.BudgetID       = envelopeBeforeUpdate.BudgetID;
            envelope.CurrentBalance = envelopeBeforeUpdate.CurrentBalance;

            decimal difference = envelopeBeforeUpdate.StartingBalance - envelope.StartingBalance;
            envelope.CurrentBalance -= difference;

            uow.EnvelopeRepository.Detach(envelopeBeforeUpdate);
            uow.EnvelopeRepository.Update(envelope);
            uow.Save();
        }
示例#5
0
 public void ResetEnvelope(Envelope envelope)
 {
     envelope.CurrentBalance = envelope.StartingBalance;
     uow.EnvelopeRepository.Update(envelope);
     uow.Save();
 }
        public JsonResult Edit(Envelope envelope)
        {
            Services.EnvelopeService.UpdateEnvelope(envelope);

            return Json(new { success = true, data = new { envelope.EnvelopeID, envelope.Title, envelope.CurrentBalance, envelope.StartingBalance } });
        }
        public JsonResult Create(string username, Envelope envelope)
        {
            Services.EnvelopeService.InsertEnvelope(envelope, username);

            return Json(new { success = true, data = new { envelope.EnvelopeID, envelope.Title, envelope.CurrentBalance, envelope.StartingBalance } });
        }
 public ActionResult Edit(Envelope envelope)
 {
     if (ModelState.IsValid)
     {
         Services.EnvelopeService.UpdateEnvelope(envelope);
         return RedirectToAction("Index");
     }
     return View(envelope);
 }