public async System.Threading.Tasks.Task <ActionResult> Create([Bind(Include = "tp_fname,tp_lname,is_Admin,tp_email")] TraficPolice traficPolice, HttpPostedFileBase profilepic, string State)
        {
            if (ModelState.IsValid)
            {
                Random       r     = new Random();
                string       state = State.Substring(0, 2);
                TraficPolice tp;
                do
                {
                    string id = "TP" + state + r.Next(10000, 100000);
                    traficPolice.TP_ID = id;
                    tp = db.TPs.Find(id);
                } while (tp != null);


                traficPolice.tp_password = traficPolice.tp_fname.Substring(0, 3) + "@" + State.Substring(2, 5) + "1";
                traficPolice.tp_posting  = State.Substring(2).ToUpper();
                traficPolice.tp_fname    = traficPolice.tp_fname.ToUpper();
                traficPolice.tp_lname    = traficPolice.tp_lname.ToUpper();
                if (profilepic != null)
                {
                    if (profilepic.ContentType == "image/jpg" || profilepic.ContentType == "image/jpeg" || profilepic.ContentType == "image/png")
                    {
                        string ext = System.IO.Path.GetExtension(profilepic.FileName);
                        profilepic.SaveAs(Server.MapPath("/") + "/Content/PolicememberProfilePhoto/" + traficPolice.TP_ID + ext);
                        traficPolice.image_url = traficPolice.TP_ID + ext;
                    }
                    else
                    {
                        TempData["ErrorMsg"] = "image must be in formate of jpg/png/jpeg only";
                        return(RedirectToAction("Create"));
                    }
                }

                db.TPs.Add(traficPolice);
                db.SaveChanges();
                var user = new ApplicationUser {
                    UserName = traficPolice.TP_ID, Email = traficPolice.tp_email
                };
                var result = await UserManager.CreateAsync(user, traficPolice.tp_password);

                if (result.Succeeded)
                {
                }
                return(RedirectToAction("Index"));
            }

            return(View(traficPolice));
        }
        public ActionResult changepass(string password, string repassword)
        {
            if (Request.Cookies.Get("sotp") != null)
            {
                if (password.Equals(repassword))
                {
                    string       email = Request.Cookies["temail"].Value.ToString();
                    TraficPolice pu    = db.TPs.Where(p => p.tp_email == email).FirstOrDefault();
                    pu.tp_password = password;

                    db.SaveChanges();

                    Response.Cookies["rotp"].Expires   = DateTime.Now.AddDays(-1);
                    Response.Cookies["temail"].Expires = DateTime.Now.AddDays(-1);
                    ViewBag.msg1 = "Password Changed Successfully. Login by New Password";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.msg = "Both password must be same!!!";
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("forgot", "PULogin"));
            }
        }