public async Task <IActionResult> Post([FromBody] AdminTbl value) { // check if the User exists in the DB if (await dbContext.AdminTbl.AnyAsync(User => User.UserName.Equals(value.UserName))) { AdminTbl admin = await dbContext.AdminTbl.Where(admin => admin.UserName.Equals(value.UserName)).FirstAsync(); //calculate hash password and compare to DB var client_post_hash_password = Convert.ToBase64String(Common.SaltHashPassword( Encoding.ASCII.GetBytes(value.Password), Convert.FromBase64String(admin.Salt))); if (client_post_hash_password.Equals(admin.Password)) { return(StatusCode(StatusCodes.Status200OK, JsonConvert.SerializeObject(admin.UserName))); } else { return(StatusCode(StatusCodes.Status400BadRequest, JsonConvert.SerializeObject("Wrong Credentials"))); } } else { return(StatusCode(StatusCodes.Status400BadRequest, JsonConvert.SerializeObject("Wrong Credentials"))); } }
public ActionResult AdminGetir(AdminTbl p) { AdminTbl deger = admin.Find(x => x.ID == p.ID); deger.ID = p.ID; deger.KullaniciAdi = p.KullaniciAdi; deger.KullaniciAdi = p.KullaniciAdi; admin.TUpdate(deger); return(RedirectToAction("AdminListele")); }
public ActionResult Login(Login login) { AdminTbl admin = db.AdminTbl.FirstOrDefault(x => x.Email == login.Email && x.Password == login.Password); if (admin == null) { ViewBag.message = "მომხმარებლის სახელი ან პაროლი არასწორია"; return(View()); } else { Session["admin"] = admin; return(RedirectToAction("Adminpanel", "Administrator")); } }
// GET: Login public ActionResult Index(AdminTbl p) { DbCvEntities db = new DbCvEntities(); var bilgi = db.AdminTbl.FirstOrDefault(x => x.KullaniciAdi == p.KullaniciAdi && x.Sifre == p.Sifre); if (bilgi != null) { FormsAuthentication.SetAuthCookie(bilgi.KullaniciAdi, false); Session["KullaniciAdi"] = bilgi.KullaniciAdi.ToString(); return(RedirectToAction("DeneyimListele", "Deneyim")); } else { return(View("Index")); } }
public ActionResult UserProfile(AdminTbl admin) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:64189/api/student"); //HTTP POST var putTask = client.PutAsJsonAsync <AdminTbl>("API_CONTROLLER_NAME", admin); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("UserProfile")); } } return(View(admin)); }
public ActionResult UserProfile() { AdminTbl admin = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://servicedeliveryapi.azurewebsites.net/"); //HTTP GET var responseTask = client.GetAsync("API_CONTROLLER_NAME/"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <AdminTbl>(); readTask.Wait(); admin = readTask.Result; } } return(View(admin)); }
public ActionResult AdminGetir(int id) { AdminTbl t = admin.Find(x => x.ID == id); return(View(t)); }
public ActionResult AdminEkle(AdminTbl p) { admin.TAdd(p); return(RedirectToAction("AdminListele")); }