public bool CreateFullProject(FullProjectCreate model) { var entity = new FullProject() { OwnerId = _userId, //FullProjectId = model.FullProjectId, DIYId = model.DIYId, SupplyId = model.SupplyId, RoadblockId = model.RoadblockId }; using (var ctx = new ApplicationDbContext()) { ctx.FullProjects.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(FullProjectCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateFullProjectService(); if (service.CreateFullProject(model)) { ViewBag.SaveResult = "Your project was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Project could not be created."); return(View(model)); }