public async Task<ActionResult> Login(DoctorsRegistrationViewModel model, string returnUrl) { if (!ModelState.IsValid) { return View(model); } DateTime today = DateTime.Today;
public async Task <ActionResult> Login(DoctorsRegistrationViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } DateTime today = DateTime.Today; // DateTime now = DateTime.Now; string newFileName = "G:\\DateTime" + DateTime.Today.ToString("yyyyMMdd_hhmmss") + ".csv"; // string newFileName = "G:\\question1.csv"; string row = model.FirstName + "," + model.LastName + "," + model.EmailId + "," + model.PhoneNumber + "," + model.Gender + "," + model.ShortProfile + "," + model.RegistrationNumber + "," + model.DateOfBirth + model.Specality + model.YearsOfExperience + Environment.NewLine; // string row = model.Email + Environment.NewLine; if (!System.IO.File.Exists(newFileName)) { row = "FirstName,LastName,Email,PhoneNumber,Gender,ShortProfile,RegistrationNumber,DateOfBirth,Specality,YearsOfExperience" + Environment.NewLine; // row = "FirstName" + Environment.NewLine; System.IO.File.WriteAllText(newFileName, row); } System.IO.File.AppendAllText(newFileName, row); Response.Write("<script>alert(' Registration Successful.')</script>"); // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.FirstName, model.LastName, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public async Task <ActionResult> Login(DoctorsRegistrationViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } DateTime today = DateTime.Today; // DateTime now = DateTime.Now; // string targetpath = Server.MapPath("~/Doc/"); // var path = Path.Combine(Server.MapPath("~/Contents/Images"), fileName); ("~/Contents/Excel"),+DateTime.Today.ToString("yyyyMMdd_hhmmss") + ".csv"; //string newFileName; //var path = Server.MapPath(@"~/Contents/DateTime" + DateTime.Today.ToString("yyyyMMdd_hhmmss") + ".csv"); //using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, true)) //{ // //file.WriteLine(model.newFileName.ToString()); //} string newFileName = Server.MapPath(@"~/Contents/DateTime" + DateTime.Today.ToString("yyyyMMdd_hhmmss") + ".csv"); //string newFileName = "G:\\DateTime" + DateTime.Today.ToString("yyyyMMdd_hhmmss") + ".csv"; // string newFileName = Server.MapPath("~excelsheet"); // const string path = "/Doc/Users.xlsx"; // string targetpath = Server.MapPath("~/Doc/"); // var path = Path.Combine(Server.MapPath("~/Contents/Images"), fileName); // string newFileName = "G:\\question1.csv"; string row = model.FirstName + "," + model.LastName + "," + model.EmailId + "," + model.PhoneNumber + "," + model.Gender + "," + model.ShortProfile + "," + model.RegistrationNumber + "," + model.DateOfBirth + model.Specality + model.YearsOfExperience + Environment.NewLine; // string row = model.Email + Environment.NewLine; if (!System.IO.File.Exists(newFileName)) { row = "FirstName,LastName,Email,PhoneNumber,Gender,ShortProfile,RegistrationNumber,DateOfBirth,Specality,YearsOfExperience" + Environment.NewLine; // row = "FirstName" + Environment.NewLine; System.IO.File.WriteAllText(newFileName, row); } System.IO.File.AppendAllText(newFileName, row); Response.Write("<script>alert(' Registration Successful.')</script>"); // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.FirstName, model.LastName, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: return(RedirectToAction("Index", "Account")); // return RedirectToLocal(Index); case SignInStatus.LockedOut: return(View("Index")); //return View("Lockout"); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: // ModelState.AddModelError("", "valid login attempt."); return(View(model)); } }