public ActionResult Register(RegisterModel model) { var db = new CourseLearnerContext(); if (ModelState.IsValid) { // Attempt to register the user try { WebSecurity.CreateUserAndAccount(model.UserName, model.Password); WebSecurity.Login(model.UserName, model.Password); var objCourseUser = new CourseUserDetail(); objCourseUser.UserID = Convert.ToInt32(Membership.GetUser(model.UserName).ProviderUserKey); objCourseUser.FirstName = model.FirstName; objCourseUser.LastName = model.LastName; objCourseUser.ContactAddress = model.AboutMe; objCourseUser.dateOfBirth = DateTime.UtcNow; objCourseUser.userType = model.isStudent; db.CourseUser.Add(objCourseUser); db.SaveChanges(); return RedirectToAction("Index", "Home"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }
public CourseLearnerGenericRepo() { dbcontext = new CourseLearnerContext(); dbset = dbcontext.Set <T>(); }
public HomeController() { objContext = new CourseLearnerContext(); }