public bool CreatePaychecks(PaychecksCreate model, int moneyFlowID) { var entity = new Paychecks() { OwnerID = _userID, MoneyFlowID = moneyFlowID, Name = model.Name, AmountPaid = model.AmountPaid, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Paychecks.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(PaychecksCreate model, int moneyFlowID) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePaychecksService(); if (service.CreatePaychecks(model, moneyFlowID)) { TempData["SaveResult"] = "Your Paychecks were created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Paychecks could not be created."); return(View(model)); }