public ActionResult Create(StepCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateStepService(); if (service.CreateStep(model)) { TempData["SaveResult"] = "Your Step was created."; return(RedirectToAction("Index")); } return(View(model)); }
public bool CreateStep(StepCreate model) { var entity = new Step { UserId = _userId, StepType = model.StepType, Name = model.Name, Description = model.Description, FinalPageDetail = model.FinalPageDetail, ImageLink = model.ImageLink, IsSaved = true }; using (var ctx = new ApplicationDbContext()) { ctx.Steps.Add(entity); return(ctx.SaveChanges() == 1); } }