////////////////////////////////////////////////////////// public IActionResult Index() { ///////////////////////////////////////////////////////////////////////////////////////////////////////////count msg menu.resiver = db.Tbl_Message.Where(a => a.StateMess == false && a.SenderMess == "admin" && a.ResiverMess == User.Identity.GetId()).Count(); menu.sender = db.Tbl_Message.Where(a => a.StateMess == false && a.SenderMess == User.Identity.GetId()).Count(); /////////////////////////////////////////////////////////////////////////////////////////////////////eror message if (eror != null) { ViewBag.err = eror; eror = null; } var quser = db.Tbl_User.Where(a => a.Id == Convert.ToInt32(User.Identity.GetId())).SingleOrDefault(); Vm_User us = new Vm_User() { UserNameUs = quser.UserNameUs, PhoneUs = quser.PhoneUs, ProfileImageUs = quser.ProfileImageUs, PasswordUs = quser.PasswordUs, AddressUs = quser.AddressUs, }; return(View(us)); }
public IActionResult otpconfig(Vm_User us) { ViewBag.Mobile = mobile; var q = _db.tbl_Users.Where(a => a.phone == mobile).SingleOrDefault(); if (q.token == us.token) { var claims = new List <Claim> () { new Claim(ClaimTypes.NameIdentifier, q.phone), new Claim(ClaimTypes.Name, "") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = true }; HttpContext.SignInAsync(principal, properties); return(RedirectToAction("mapclient", "mapclient")); } else { ViewBag.msg = "رمز وردی نادرست است"; return(View()); } return(View()); }
public IActionResult add(Vm_User us) { if (us.UserNameUs == "admin") { eror = "نام ورودی غیر قابل قبول است "; return(RedirectToAction("register")); } if (us.PasswordUs != us.repass) { eror = "رمز های وارد شده با هم مطابقت ندارند "; return(RedirectToAction("register")); } else if (db.Tbl_User.Any(a => a.PhoneUs == us.PhoneUs)) { eror = "شماره تلفن مورد نظر قبلا ثبت شده است "; return(RedirectToAction("register")); } else { Tb_User tb = new Tb_User() { UserNameUs = us.UserNameUs, PasswordUs = us.PasswordUs, PhoneUs = us.PhoneUs }; db.Tbl_User.Add(tb); db.SaveChanges(); suc = "ثبت نام با موفقیت انجام شد"; return(RedirectToAction("register")); } }
public IActionResult add(Vm_User us) { if (us.UserNameUs == "admin") { eror = "Giriş adı kabul edilmiyor "; return(RedirectToAction("register")); } if (us.PasswordUs != us.repass) { eror = "Girilen şifreler uyuşmuyor "; return(RedirectToAction("register")); } else if (db.Tbl_User.Any(a => a.PhoneUs == us.PhoneUs)) { eror = "İstenen telefon numarası zaten kayıtlı "; return(RedirectToAction("register")); } else { Tb_User tb = new Tb_User() { UserNameUs = us.UserNameUs, PasswordUs = us.PasswordUs, PhoneUs = us.PhoneUs }; db.Tbl_User.Add(tb); db.SaveChanges(); suc = "Kayıt başarıyla tamamlandı"; return(RedirectToAction("register")); } }
public IActionResult add(Vm_User us) { if (us.UserNameUs == "admin") { eror = "اسم الإدخال غير مقبول "; return(RedirectToAction("register")); } if (us.PasswordUs != us.repass) { eror = "كلمات السر التي تم ادخالها غير مطابقة "; return(RedirectToAction("register")); } else if (db.Tbl_User.Any(a => a.PhoneUs == us.PhoneUs)) { eror = "رقم الهاتف ذو الصلة مسجل بالفعل "; return(RedirectToAction("register")); } else { Tb_User tb = new Tb_User() { UserNameUs = us.UserNameUs, PasswordUs = us.PasswordUs, PhoneUs = us.PhoneUs }; db.Tbl_User.Add(tb); db.SaveChanges(); suc = "تم التسجيل بنجاح"; return(RedirectToAction("register")); } }
////////////////////////////////////////////////////////// public IActionResult Index() { if (menu.idrezerv != 0) { int id = menu.idrezerv; menu.idrezerv = 0; return(RedirectToAction("details", "product", new{ id = id })); } setdata(); /////////////////////////////////////////////////////////////////////////////////////////////////////eror message if (eror != null) { ViewBag.err = eror; eror = null; } var quser = db.Tbl_User.Where(a => a.Id == Convert.ToInt32(User.Identity.GetId())).SingleOrDefault(); Vm_User us = new Vm_User() { UserNameUs = quser.UserNameUs, PhoneUs = quser.PhoneUs, ProfileImageUs = quser.ProfileImageUs, PasswordUs = quser.PasswordUs, AddressUs = quser.AddressUs, }; return(View(us)); }
public IActionResult add(Vm_User us) { if (us.UserNameUs == "admin") { eror = "Input name is not acceptable"; return(RedirectToAction("register")); } if (us.PasswordUs != us.repass) { eror = "The passwords entered do not match"; return(RedirectToAction("register")); } else if (db.Tbl_User.Any(a => a.PhoneUs == us.PhoneUs)) { eror = "The phone number in question has already been registered"; return(RedirectToAction("register")); } else { Tb_User tb = new Tb_User() { UserNameUs = us.UserNameUs, PasswordUs = us.PasswordUs, PhoneUs = us.PhoneUs }; db.Tbl_User.Add(tb); db.SaveChanges(); suc = "Registration completed successfully"; return(RedirectToAction("register")); } }
public IActionResult login_check(Vm_User us) { var user = db.Tbl_User.Where(a => a.UserNameUs == "admin").SingleOrDefault(); if (user.PasswordUs == us.PasswordUs && us.UserNameUs == "admin") { menu.img = user.ProfileImageUs; menu.resiver = db.Tbl_Message.Where(a => a.StateMess == false && a.SenderMess != "admin").Count(); menu.sender = db.Tbl_Message.Where(a => a.StateMess == false && a.SenderMess == "admin").Count(); if (user.ProfileImageUs == null) { var claims = new List <Claim>() { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, "admin") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = true }; HttpContext.SignInAsync(principal, properties); return(RedirectToAction("Index", "Home", new { area = "admin" })); } else { var claims = new List <Claim>() { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, "admin") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.AddDays(360) }; HttpContext.SignInAsync(principal, properties); return(RedirectToAction("Index", "Home", new { area = "admin" })); } } eror = "نام کاربری یا رمز عبور شما نادرست است"; return(RedirectToAction("Index")); }
public async Task <IActionResult> edit(Vm_User vmus) { var edituser = db.Tbl_Users.Where(a => a.Id == vmus.Id).SingleOrDefault(); edituser.Name = vmus.Name; edituser.Family = vmus.Family; edituser.Age = vmus.Age; edituser.Address = vmus.Address; edituser.CodeNational = vmus.CodeNational; if (vmus.File != null) { /////upload file Image string FileExtension1 = Path.GetExtension(vmus.File.FileName); NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{env.WebRootPath}\\Upload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await vmus.File.CopyToAsync(stream); } ////end upload file Image edituser.Image = NewFileName; } if (vmus.FileUpload != null) { /////upload file string FileExtension1 = Path.GetExtension(vmus.FileUpload.FileName); NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{env.WebRootPath}\\Upload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await vmus.FileUpload.CopyToAsync(stream); } ////end upload file edituser.FileName = NewFileName; } if (vmus.VideoUpload != null) { /////upload file Video string FileExtension1 = Path.GetExtension(vmus.VideoUpload.FileName); NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{env.WebRootPath}\\Upload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await vmus.VideoUpload.CopyToAsync(stream); } ////end upload file Video edituser.VideoName = NewFileName; } db.Tbl_Users.Update(edituser); db.SaveChanges(); massage = "اطلاعات شما با موفقیت تغییر یافت"; return(RedirectToAction("list")); }
public IActionResult login_check(Vm_User us) { var user = db.Tbl_User.Where(a => a.PhoneUs == us.PhoneUs && a.PasswordUs == us.PasswordUs && a.UserNameUs != "admin").SingleOrDefault(); if (user != null) { if (user.ProfileImageUs == null) { var claims = new List <Claim>() { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, "profile.png") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = true }; HttpContext.SignInAsync(principal, properties); return(RedirectToAction("index", "profile", new { area = "area" })); } else { var claims = new List <Claim>() { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, user.ProfileImageUs) }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = true }; HttpContext.SignInAsync(principal, properties); return(RedirectToAction("index", "profile")); } } eror = "اسم المستخدم أو كلمة المرور خاطئة"; return(RedirectToAction("index")); }
//edit public IActionResult edit() { var q = _db.tbl_Users.Where(a => a.phone == User.Identity.GetId()).SingleOrDefault(); Vm_User B = new Vm_User() { NameFamily = q.NameFamily, Adress = q.Adress, photo = q.photo, phone = q.phone }; return(View(B)); }
public IActionResult edit(int id) { var edituser = db.Tbl_Users.Where(a => a.Id == id).SingleOrDefault(); Vm_User vmus = new Vm_User() { Name = edituser.Name, Family = edituser.Family, Age = edituser.Age, Address = edituser.Address, CodeNational = edituser.CodeNational, Image = edituser.Image, FileName = edituser.FileName, VideoName = edituser.VideoName }; return(View(vmus)); }
public async Task <IActionResult> add(Vm_User us) { if (us.UserNameUs == "admin") { eror = "İsim kabul edilmedi"; return(RedirectToAction("index")); } if (us.img != null) { ///////////////upload file string FileExtension1 = Path.GetExtension(us.img.FileName); NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{_env.WebRootPath}\\fileupload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await us.img.CopyToAsync(stream); } //////////////////////////end upload file var quser = db.Tbl_User.Where(a => a.Id == Convert.ToInt32(User.Identity.GetId())).SingleOrDefault(); quser.UserNameUs = us.UserNameUs; quser.PasswordUs = us.PasswordUs; quser.AddressUs = us.AddressUs; quser.ProfileImageUs = NewFileName; quser.Language = "fa"; db.Tbl_User.Update(quser); db.SaveChanges(); eror = "Bilgiler başarıyla güncellendi."; return(RedirectToAction("index")); } else { var quser = db.Tbl_User.Where(a => a.Id == Convert.ToInt32(User.Identity.GetId())).SingleOrDefault(); quser.UserNameUs = us.UserNameUs; quser.PasswordUs = us.PasswordUs; quser.Language = "fa"; quser.AddressUs = us.AddressUs; db.Tbl_User.Update(quser); db.SaveChanges(); eror = "Bilgiler başarıyla güncellendi."; return(RedirectToAction("index")); } }
public async Task <IActionResult> add(Vm_User us) { // if (db.Tbl_User.Any(a=>a.PhoneUs==us.PhoneUs)) // { // eror="شماره تماس قبلا ثبت شده است."; // return RedirectToAction("index","profile",new {Areas="admin"}); // } if (us.img != null) { ///////////////upload file string FileExtension1 = Path.GetExtension(us.img.FileName); NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{_env.WebRootPath}\\fileupload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await us.img.CopyToAsync(stream); } //////////////////////////end upload file var quser = db.Tbl_User.Where(a => a.Id == Convert.ToInt32(User.Identity.GetId())).SingleOrDefault(); quser.PhoneUs = us.PhoneUs; quser.PasswordUs = us.PasswordUs; quser.AddressUs = us.AddressUs; quser.ProfileImageUs = NewFileName; quser.Language = "fa"; db.Tbl_User.Update(quser); db.SaveChanges(); eror = "اطلاعات با موفقیت بروز رسانی شد."; return(RedirectToAction("index", "profile", new { Areas = "admin" })); } else { var quser = db.Tbl_User.Where(a => a.Id == Convert.ToInt32(User.Identity.GetId())).SingleOrDefault(); quser.PhoneUs = us.PhoneUs; quser.PasswordUs = us.PasswordUs; quser.Language = "fa"; quser.AddressUs = us.AddressUs; db.Tbl_User.Update(quser); db.SaveChanges(); eror = "اطلاعات با موفقیت بروز رسانی شد."; return(RedirectToAction("index", "profile", new { Areas = "admin" })); } }
public async Task <IActionResult> edit(Vm_User A) { var q = _db.tbl_Users.Where(a => a.phone == User.Identity.GetId()).SingleOrDefault(); if (A.photos != null) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////upload file string FileExtension1 = Path.GetExtension(A.photos.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.photos.CopyToAsync(stream); } q.NameFamily = A.NameFamily; q.Adress = A.Adress; q.photo = NewFileName; //////////////////////////end upload file } else { q.NameFamily = A.NameFamily; q.Adress = A.Adress; } _db.tbl_Users.Update(q); _db.SaveChanges(); ///name.photo.credit // Menu.name=_db.tbl_Users.Where(a=>a.phone==User.Identity.GetId())?.SingleOrDefault().NameFamily; // Menu.photo=_db.tbl_Users.Where(a=>a.phone==User.Identity.GetId())?.SingleOrDefault().photo; // // HttpContext.Session.SetString("name", _db.tbl_Users.Where(a => a.phone == User.Identity.GetId())?.SingleOrDefault().NameFamily); HttpContext.Session.SetString("photo", _db.tbl_Users.Where(a => a.phone == User.Identity.GetId())?.SingleOrDefault().photo); return(RedirectToAction("index")); }
public IActionResult sendtoken(Vm_User us) { Random rnd = new Random(); string number = rnd.Next(1000, 9999).ToString(); mobile = us.phone; var qcheck = _db.tbl_Users.Where(a => a.phone == us.phone).SingleOrDefault(); if (qcheck == null) { Tbl_User user = new Tbl_User() { phone = us.phone, token = number, NameFamily = "نام شما", Adress = "آدرس شما ", photo = "9.jpg" }; _db.tbl_Users.Add(user); _db.SaveChanges(); var api = new KavenegarApi("3871353043697339486A70384F544A4A574C74612B51432F4C7A4B305076645457396F5267456F7A5A34383D"); api.VerifyLookup(us.phone, number, "taxijo"); return(RedirectToAction("otpconfig")); } else { qcheck.token = number; _db.tbl_Users.Update(qcheck); _db.SaveChanges(); var api = new KavenegarApi("3871353043697339486A70384F544A4A574C74612B51432F4C7A4B305076645457396F5267456F7A5A34383D"); api.VerifyLookup(us.phone, number, "taxijo"); return(RedirectToAction("otpconfig")); } return(RedirectToAction("otpconfig")); }
////////////////////////////////////////////////////////////////////add informations public async Task <IActionResult> add(Vm_User vmus) { if (db.Tbl_Users.Any(a => a.CodeNational == vmus.CodeNational)) { massage = "اطلاعات فردی با این کد ملی قبلا ثبت شده است"; return(RedirectToAction("index")); } /////upload Image string FileExtension1 = Path.GetExtension(vmus.File.FileName); NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension1); var path = $"{env.WebRootPath}\\Upload\\{NewFileName}"; using (var stream = new FileStream(path, FileMode.Create)) { await vmus.File.CopyToAsync(stream); } ////end upload Image /////upload file string FileExtension2 = Path.GetExtension(vmus.FileUpload.FileName); NewFileName2 = String.Concat(Guid.NewGuid().ToString(), FileExtension2); var path2 = $"{env.WebRootPath}\\Upload\\{NewFileName2}"; using (var stream = new FileStream(path2, FileMode.Create)) { await vmus.FileUpload.CopyToAsync(stream); } ////end upload file /////upload Video string FileExtension3 = Path.GetExtension(vmus.VideoUpload.FileName); NewFileName3 = String.Concat(Guid.NewGuid().ToString(), FileExtension3); var path3 = $"{env.WebRootPath}\\Upload\\{NewFileName3}"; using (var stream = new FileStream(path3, FileMode.Create)) { await vmus.VideoUpload.CopyToAsync(stream); } ////end upload Video Tbl_User tbus = new Tbl_User() { Name = vmus.Name, Family = vmus.Family, Age = vmus.Age, Address = vmus.Address, CodeNational = vmus.CodeNational, Image = NewFileName, FileName = NewFileName2, VideoName = NewFileName3, Description = vmus.Description }; db.Tbl_Users.Add(tbus); db.SaveChanges(); massage = "اطلاعات شما با موفقیت ثبت شد"; return(RedirectToAction("index")); }