public bool IsSuccessfulRegisteration(RegisterModel regMod) { bool isSuccess = false; userRep.RegisterNewUser(regMod); isSuccess = true; return isSuccess; }
public void RegisterNewUser(RegisterModel regMod) { User user = new User(); user.fname = regMod.FirstName; user.lname = regMod.LastName; user.UserID = regMod.UserName; user.Password = regMod.Password; user.addr1 = regMod.Address1; user.addr2 = regMod.Address2; user.city = regMod.City; user.state = regMod.State; user.zip = regMod.ZipCode; user.phNo = regMod.PhoneNumber; user.user_type = regMod.EnrollAs; context.Users.Add(user); if (regMod.EnrollAs == 1) { MentorProfile mp = new MentorProfile(); mp.description = null; mp.imgPath = "/Uploads/UserImage/m1.jpeg"; mp.major = null; mp.User = user; context.MentorProfiles.Add(mp); List<weekday> weekdays = context.weekdays.Select(w => w).ToList(); List<time> times = context.times.Select(w => w).ToList(); foreach (weekday w in weekdays) { foreach (time t in times) { MentorSchedule ms = new MentorSchedule(); ms.fk_day_Id = w.dayid; ms.fk_time_id = t.timeid; ms.MentorProfile = mp; ms.fk_mentorship_id = null; ms.isMentoring = 0; context.MentorSchedules.Add(ms); } } } else if (regMod.EnrollAs == 2) { StudentProfile mp = new StudentProfile(); mp.description = null; mp.imgPath = "/Uploads/UserImage/m2.jpeg"; mp.clas = null; mp.User = user; context.StudentProfiles.Add(mp); List<weekday> weekdays = context.weekdays.Select(w => w).ToList(); List<time> times = context.times.Select(w => w).ToList(); foreach (weekday w in weekdays) { foreach (time t in times) { StudentSchedule ms = new StudentSchedule(); ms.fk_day_Id = w.dayid; ms.fk_time_id = t.timeid; ms.StudentProfile = mp; ms.fk_mentorship_id = null; context.StudentSchedules.Add(ms); } } } context.SaveChanges(); }
public ActionResult Register(RegisterModel regDetails) { if (coreAcc.IsSuccessfulRegisteration(regDetails)) { System.Web.HttpContext.Current.Session["username"] = regDetails.UserName; System.Web.HttpContext.Current.Session["usertype"] = regDetails.EnrollAs; System.Web.HttpContext.Current.Session["fname"] = regDetails.FirstName; if (regDetails.EnrollAs == 1) { return RedirectToAction("Index", "Mentor"); } else if (regDetails.EnrollAs == 2) { return RedirectToAction("Index", "Student"); } } return View(); }