public bool CreateDIY(DIYCreate model) { var entity = new DIY() { OwnerId = _userId, ProjectName = model.ProjectName, StartDate = model.StartDate, EndDate = model.EndDate, BudgetedAmount = model.BudgetedAmount, }; using (var ctx = new ApplicationDbContext()) { ctx.DIYs.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(DIYCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateDIYService(); if (service.CreateDIY(model)) { TempData["SaveResult"] = "Your project was created."; return(RedirectToAction("Create", "Supply")); } ModelState.AddModelError("", "Project could not be created."); return(View(model)); }