public bool CreateMoneyFlow(MoneyFlowCreate model) { var entity = new MoneyFlow() { OwnerID = _userID, Revenue = model.Revenue, Expenses = model.Expenses, TaxesSum = model.TaxesSum, Profit = model.Profit, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.MoneyFlow.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(MoneyFlowCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateMoneyFlowService(); if (service.CreateMoneyFlow(model)) { TempData["SaveResult"] = "Your MoneyFlow was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "MoneyFlow could not be created."); return(View(model)); }