示例#1
0
        // GET: PaymentReceived/Create
        public ActionResult Create()
        {
            var sourceService         = CreateSourceService();
            var sourceNames           = sourceService.GetSourceNames();
            var paymentReceivedCreate = new PaymentReceivedCreate()
            {
                SourceEntityNames = sourceNames
            };

            return(View(paymentReceivedCreate));
        }
 public bool CreatePaymentReceived(PaymentReceivedCreate model)
 {
     using (var context = new ApplicationDbContext())
     {
         var paymentReceivedEntity = new PaymentReceived()
         {
             SourceId    = context.Sources.SingleOrDefault(c => c.Name == model.SourceName && c.UserId == _userId).Id,
             MonthId     = context.Months.SingleOrDefault(m => m.BeginDate.Month == DateTime.Now.Month && m.BeginDate.Year == DateTime.Now.Year && m.UserId == _userId).Id,
             Amount      = model.Amount,
             PaymentDate = DateTime.Now,
             UserId      = _userId
         };
         context.PaymentsReceived.Add(paymentReceivedEntity);
         return(context.SaveChanges() == 1);
     }
 }
示例#3
0
        public ActionResult Create(PaymentReceivedCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreatePaymentReceivedService();

            if (service.CreatePaymentReceived(model))
            {
                TempData["SaveResult"] = "Your payment was created.";
                return(RedirectToAction("CurrentBudget", "Month"));
            }

            ModelState.AddModelError("", "Payment could not be created.");
            return(View(model));
        }