public ActionResult EditClass(ClassVM vm) { if (!ModelState.IsValid) { return(View(vm)); } //if (repo.GetByTitle(vm.Title).ClassId != vm.ClassId) // { // ViewBag.err = "A Class with the same title exits. Try a different title"; // return View(vm); // } var cls = new Class { Title = vm.Title, Description = vm.Description, CategoryId = vm.CategoryId, Price = vm.Price, LevelId = vm.LevelId, TypeId = vm.TypeId, Requirements = vm.Requirements, TargetStudents = vm.TargetStudents, ClassId = vm.ClassId, DateCreated = vm.DateCreated, PosterSrc = vm.PosterSrc }; //commit changes to db _db.Entry(cls).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Edit", new { id = cls.ClassId })); //try // { // //if we got here it means everything is OK! // } //catch (Exception e) // { // ViewBag.err = e.Message; // var cls = CompleteClass(); // return PartialView(cls); // } }
public bool CreateUser(User user) { _dbContext.Add <User>(user); return(_dbContext.SaveChanges() > 0 ? true : false); }