public ActionResult Registration(RegistrationViewModel model) { if (ModelState.IsValid) { if (model.Type == "Doctor") { DoctorProfileModel doctor = new DoctorProfileModel(); doctor.FullName = model.Name; doctor.Email = model.Email; doctor.Password = model.Password; doctor.Gender = "Female"; doctor.Specialist = "Dentist"; doctor.Location = "Rajshahi"; doctor.Phone = "017XXXXXXXX"; doctor.NewFee = 1000; doctor.OldFee = 750; _doctorProfileService.Insert(doctor); return(RedirectToAction("Login", "Account")); } else if (model.Type == "Patient") { PatientProfileModel patient = new PatientProfileModel(); patient.Name = model.Name; patient.Email = model.Email; patient.Password = model.Password; patient.Gender = "Female"; patient.BloodGroup = "B+"; patient.District = "Dhaka"; _patientProfileService.Insert(patient); return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Login", "Account")); } else { return(View(model: model)); } }
public ActionResult Registration(RegistrationViewModel model) { bool statusRegistration = false; string messageRegistration = string.Empty; if (ModelState.IsValid) { // Email Verification string userName = Membership.GetUserNameByEmail(model.Email); if (!string.IsNullOrEmpty(userName)) { ModelState.AddModelError("Warning Email", "Sorry: Email already Exists"); return(View(model)); } //Save User Data using (TransactionScope scope = new TransactionScope()) { try { var user = new User() { Username = model.Name, Email = model.Email, Password = model.Password, ActivationCode = Guid.NewGuid(), IsActive = true }; int UserId = _helper.CreateUser(user); int RoleId = _helper.GetRoleIdByRoleName(model.Type); _helper.CreateRole(UserId, RoleId); if (model.Type == "Doctor") { DoctorProfileModel doctor = new DoctorProfileModel(); doctor.FullName = model.Name; doctor.Email = model.Email; doctor.Password = model.Password; //doctor.Gender = "Female"; //doctor.Specialist = "Dentist"; //doctor.Location = "Rajshahi"; //doctor.Phone = "017XXXXXXXX"; //doctor.NewFee = 1000; //doctor.OldFee = 750; _doctorProfileService.Insert(doctor); scope.Complete(); return(RedirectToAction("Login", "Account")); } else if (model.Type == "Patient") { PatientProfileModel patient = new PatientProfileModel(); patient.Name = model.Name; patient.Email = model.Email; patient.Password = model.Password; //patient.Gender = "Female"; //patient.BloodGroup = "B+"; //patient.District = "Dhaka"; _patientProfileService.Insert(patient); scope.Complete(); return(RedirectToAction("Login", "Account")); } else { return(null); } } catch (Exception ex) { // Log error scope.Dispose(); throw ex; } } ////Verification Email //messageRegistration = "Your account has been created successfully. ^_^"; //statusRegistration = true; } else { messageRegistration = "Something Wrong!"; return(View(model)); } ViewBag.Message = messageRegistration; ViewBag.Status = statusRegistration; }