public bool CreateWorkoutType(WorkoutTypeCreate model) { var entity = new WorkoutType() { UserId = _userId, Type = model.Type, }; using (var ctx = new ApplicationDbContext()) { ctx.WorkoutType.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(WorkoutTypeCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateWorkoutTypeService(); if (service.CreateWorkoutType(model)) { TempData["SaveResult"] = "New Exercise Type created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Exercise Type could not be created"); return(View(model)); }