// Create public bool CreateChecking(CheckingCreate model) { var entity = new Checking() { OwnerId = _userId, CheckingName = model.CheckingName, MonthlyBill = model.MonthlyBill, ChargeDate = model.CheckingName, DateCleared = model.DateCleared, Cleared = model.Cleared, CreatedUtc = DateTimeOffset.Now, CategoryId = model.CategoryId, UtilityCompanyId = model.UtilityCompanyId, DescriptionId = model.DescriptionId, PayingById = model.PayingById, }; using (var ctx = new ApplicationDbContext()) { ctx.Entries.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(CheckingCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateCheckingService(); if (service.CreateChecking(model)) { ViewBag.SaveResult = "Your entry was created"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Entry could not be created."); return(View(model)); }