public IActionResult CheckLogin(Vm_driver user) { var qdriver = db.Tbl_driver.Where(a => a.Username == user.Username && a.Password == user.Password).SingleOrDefault(); if (qdriver != null) { var claims = new List <Claim>() { new Claim(ClaimTypes.NameIdentifier, qdriver.Id.ToString()), new Claim(ClaimTypes.Name, "driver") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = true }; HttpContext.SignInAsync(principal, properties); return(RedirectToAction("privacy", "Home", new { area = "driver" })); } else { msg = "نام کاربری یا رمز عبور شما اشتباه است"; return(RedirectToAction("index", "login", new { area = "driver" })); } return(View()); }
//edit public IActionResult edit() { var q = db.Tbl_driver.Where(a => a.Id.ToString() == User.Identity.GetId()).SingleOrDefault(); Vm_driver B = new Vm_driver() { NameFamily = q.NameFamily, Adress = q.Adress, profile_img = q.profile_img, phone = q.phone }; return(View(B)); }
public async Task <IActionResult> edit(Vm_driver A) { var q = db.Tbl_driver.Where(a => a.Id.ToString() == User.Identity.GetId()).SingleOrDefault(); if (A.img != null) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////upload file string FileExtension1 = Path.GetExtension(A.img.FileName); string NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{_env.WebRootPath}\\fileupload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await A.img.CopyToAsync(stream); } q.NameFamily = A.NameFamily; q.Adress = A.Adress; q.profile_img = NewFileName; //////////////////////////end upload file } else { q.NameFamily = A.NameFamily; q.Adress = A.Adress; } db.Tbl_driver.Update(q); db.SaveChanges(); ///name.photo.credit HttpContext.Session.SetString("name", db.Tbl_driver.Where(a => a.Id.ToString() == User.Identity.GetId())?.SingleOrDefault().NameFamily); HttpContext.Session.SetString("photo", db.Tbl_driver.Where(a => a.Id.ToString() == User.Identity.GetId())?.SingleOrDefault().profile_img); // return(RedirectToAction("index")); }