public ActionResult Create(string ThanaID, string ClinicName) { CommunityClinic aCommunityClinic = new CommunityClinic(); aCommunityClinic.ClinicName = ClinicName; aCommunityClinic.ThanaID = Convert.ToInt32(ThanaID); db.CommunityClinics.Add(aCommunityClinic); db.SaveChanges(); int ClinicId = aCommunityClinic.CommunityClinicID; string user; string pass; //return RedirectToAction("SaveClinicResult"); RandomNumberGenerator.Create("string"); // pass = ClinicName + "_" + ThanaID; pass = GenerateRandomPassword(); user = ClinicName.Replace(" ", string.Empty).ToLower() + "_" + (db.CommunityClinics.OrderByDescending(x => x.CommunityClinicID).First().CommunityClinicID+1); int Thana = Convert.ToInt32(ThanaID); string user1 = db.Thanas.Where(x => x.ThanaID == Thana).First().ThanaName.ToLower() + "_"+(db.CommunityClinics.OrderByDescending(x => x.CommunityClinicID).First().CommunityClinicID) + 1; TempData["user"] = user; TempData["pass"] = pass; Account account = new Account() { UserName = user, Password = pass, UserRole = "Clinic", CommunityClinicID = ClinicId }; db.Accounts.Add(account); db.SaveChanges(); return Redirect("SaveClinicResult"); }
public ActionResult SaveClinic(string ThanaID, string ClinicName) { CommunityClinic aCommunityClinic = new CommunityClinic(); aCommunityClinic.ClinicName = ClinicName; aCommunityClinic.ThanaID = Convert.ToInt32(ThanaID); db.CommunityClinics.Add(aCommunityClinic); db.SaveChanges(); Console.WriteLine(Request.ServerVariables["http_referer"]); // return View("SaveClinicResult"); //return Redirect("Index"); return Index(); //return RedirectToAction("Index"); }