public void DocLoginSpecialitys(UserLoginSpeciality userloginspeciality, DocRegisterViewModel docRegVM) { userloginspeciality.LoginId = docRegVM.Userlogins.LoginId; userloginspeciality.SpecialityID = docRegVM.SpecialityID; DBcontext.UserLoginSpecialitys.Add(userloginspeciality); }
public void InsertDoctorRoles(UserLoginRole userloginRole, DocRegisterViewModel docRegVM) { userloginRole.LoginId = docRegVM.Userlogins.LoginId; userloginRole.RoleId = docRegVM.RoleId; DBcontext.UserLoginRoles.Add(userloginRole); }
public ActionResult Create() { DocRegisterViewModel _docRegisterViewModel = new DocRegisterViewModel(); _docRegisterViewModel.Specialitys = docregistor.GetSpeciality().ToList(); // _docRegisterViewModel.Userlogins = new UserLogin(); return(View(_docRegisterViewModel)); }
//[Authorize(Roles = "Admin")] public async Task <ActionResult> DocRegister(DocRegisterViewModel model) { if (ModelState.IsValid) { string fileName = Path.GetFileNameWithoutExtension(model.DisplayPicture.FileName); string fileExtension = Path.GetExtension(model.DisplayPicture.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + fileExtension; string filePathString = "/Images/Doctor_Pictures/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images/Doctor_Pictures/"), fileName); model.DisplayPicture.SaveAs(fileName); var user = new ApplicationUser { UserName = model.Email, Email = model.Email, dateOfBirth = model.DateOfBirth, Name = model.Name, PhoneNumber = model.PhoneNumber, Gender = model.Gender, doctor = new Obads2.Models.Doctor { Address = model.Address, StartTime = model.StartTime, EndTime = model.EndTime, Education = model.Education, Qualification = model.Qualification, ImageFilePath = filePathString, Speciality = model.Speciality, room = new Room() } }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, "Doctor"); //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); TempData["Success"] = "Registration Successful"; return(RedirectToAction("DocRegister", "AdminAccount", new { area = "Admin" })); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public void InsertDoctor(UserLogin userlogin, DocRegisterViewModel docRegVM) { var crypto = new SimpleCrypto.PBKDF2(); var encrypPass = crypto.Compute(docRegVM.Userlogins.Password); //userlogin.UserName = docRegVM.Userlogins.FirstName; userlogin.Password = encrypPass; userlogin.ConfirmPassword = encrypPass; userlogin.PasswordSalt = crypto.Salt; userlogin.FirstName = docRegVM.Userlogins.FirstName; userlogin.LastName = docRegVM.Userlogins.LastName; userlogin.EmailID = docRegVM.Userlogins.EmailID; userlogin.EmployeeId = 0; userlogin.IslockedOut = false; userlogin.InactiveFlag = "N"; userlogin.CreatedByID = 1; // for now we add 1 later we change userlogin.CreatedDate = DateTime.Now; userlogin.ModifiedByID = 1; // for now we add 1 later we change userlogin.ModifiedDate = DateTime.Now; userlogin.UserPhone = docRegVM.Userlogins.UserPhone; DBcontext.UserLogins.Add(userlogin); }
public ActionResult Create(DocRegisterViewModel docRegVM) { ModelState.Clear(); if (ModelState.IsValid) { var cUserEmail = db.UserLogins.FirstOrDefault(x => x.EmailID == docRegVM.Userlogins.EmailID); if (ReferenceEquals(cUserEmail, null)) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { docRegVM.RoleId = 4; generatepassword genpass = new generatepassword(); var TempPassword = genpass.generate_password(); //Take the password for email string password = TempPassword.ToString(); docRegVM.Userlogins.Password = password; //Insert data in Userlogins Table docregistor.InsertDoctor(docRegVM.Userlogins, docRegVM); docregistor.Save(); //Insert data in Login_Role Table var newUserRole = db.UserLoginRoles.Create(); docregistor.InsertDoctorRoles(newUserRole, docRegVM); docregistor.Save(); //if (registerVM.SpecialityID!=0) //{ //Insert data in Login_Speciality Table var newUserspeciality = db.UserLoginSpecialitys.Create(); docregistor.DocLoginSpecialitys(newUserspeciality, docRegVM); docregistor.Save(); // } dbContextTransaction.Commit(); // ViewBag.StatusMessage = " User Name with " + docRegVM.Userlogins.UserName + " having Email Id " + docRegVM.Userlogins.EmailID + " is created successfully"; // ViewBag.Status = 1; @TempData["SuccessMessage"] = " User Name with " + docRegVM.Userlogins.FirstName + " " + docRegVM.Userlogins.LastName + " having Email Id " + docRegVM.Userlogins.EmailID + " is created successfully"; //var callbackUrl = Url.Action("ConfirmEmail", "Account",new { userId = user.Id, code = code },protocol: Request.Url.Scheme); //get user emailid var emailid = docRegVM.Userlogins.EmailID; //send mail string subject = "MyCityMyDoctor Registration"; string body = "Dear " + docRegVM.Userlogins.FirstName + " " + docRegVM.Userlogins.LastName + "<br/> <br/>" + System.Environment.NewLine + System.Environment.NewLine + "You have been successfully registered at MyCityMyDoctor , Your login credentials are given below<br/><br/>" + "<br/><br/>Password" + " : " + password + "<br/><br/><br/>Thank You" + "<br/>Admin" + "<br/>Edox"; //edit it try { SendEMail sendemail = new SendEMail(); sendemail.Send_EMail(emailid, subject, body); @TempData["SuccessMessage"] = "User has been created Successfully. Email sent to " + docRegVM.Userlogins.EmailID + ""; } catch (Exception ex) { //ViewBag.StatusMessage = "User has been created successfully but Error occurred while sending email. Error:" + ex.Message; @TempData["Message"] = "User has been created successfully but Error occurred while sending email. Error:" + ex.Message; } } catch (DbEntityValidationException) { dbContextTransaction.Rollback(); } } } else { @TempData["Message"] = "Email ID Already Exist"; } } return(RedirectToAction("Create")); }
// // GET: Admin/Account/Register //[Authorize(Roles = "Admin")] public ActionResult DocRegister() { var model = new DocRegisterViewModel(); return(View(model)); }