public ActionResult DeleteConfirmed(int id, string username) { User_Information user_information = db.User_Information.Find(id); User_Access user_access = db.User_Access.Find(username); db.User_Information.Remove(user_information); db.User_Access.Remove(user_access); db.SaveChanges(); return(RedirectToAction("Index")); }
public Task <int> SaveNoteAsync(User_Access note) { if (note.Access_Id != 0) { return(_database.UpdateAsync(note)); } else { return(_database.InsertAsync(note)); } }
//public ActionResult Create(User_Information user_information) //{ // if (ModelState.IsValid) // { // db.User_Information.Add(user_information); // db.SaveChanges(); // return RedirectToAction("Index"); // } // ViewBag.Username = new SelectList(db.User_Access, "Username", "Password", user_information.Username); // return View(user_information); //} // // GET: /User/Edit/5 public ActionResult Edit(int id, string username) { User_Information user_information = db.User_Information.Find(id); User_Access user_access = db.User_Access.Find(username); if (user_information == null) { return(HttpNotFound()); } //ViewBag.Username = new SelectList(db.User_Access, "Username", "Password", user_information.Username); return(View(user_information)); }
public ActionResult Login(User_Access users) { if (ModelState.IsValid) { var details = from user in db.User_Access where user.Username == users.Username && user.Password == users.Password select user; if (details.FirstOrDefault() != null) { var other = from user in db.User_Information where user.Username == users.Username select user; Session["Join_Date"] = other.FirstOrDefault().Join_Date; Session["Join_Date_new"] = Convert.ToDateTime(Session["Join_Date"].ToString()).ToString("dd/MM/yyyy"); Session["Gender"] = other.FirstOrDefault().Gender; Session["ID"] = other.FirstOrDefault().ID; if (details.FirstOrDefault().Usertype == "Admin") { Session["Username"] = details.FirstOrDefault().Username; Session["Usertype"] = details.FirstOrDefault().Usertype; Session["User_Gender"] = Session["Gender"].ToString() == "Male"? "avatar5.png" : "avatar3.png"; return(RedirectToAction("AdminDashboard", "Dashboard")); } else { Session["Username"] = details.FirstOrDefault().Username; Session["Usertype"] = details.FirstOrDefault().Usertype; Session["User_Gender"] = Session["Gender"].ToString() == "Male" ? "avatar.png" : "avatar2.png"; return(RedirectToAction("StaffDashboard", "Dashboard")); } } else { ModelState.AddModelError("Error", "Wrong Username or Password"); } } else { ModelState.AddModelError("", "Invalid"); } return(View(users)); }
protected void Page_Load(object sender, EventArgs e) { User_Access user = new User_Access(); User test = new User(); test.name = "sdf0"; test.lastname = "sdfsdf"; test.password = "******"; test.username = "******"; test.created_at = 12345678910; test.uptated_at = 12312312312; test.email = "asfsdf"; var sonuc = user.Create(test); if (sonuc.Is_Success) { Label1.Text = " basarili"; } else Label1.Text = "basarisiz"; }
public ActionResult Edit(User_Information user_information, User_Access user_access) { if (ModelState.IsValid) { //db.Entry(user_access).State = EntityState.Modified; //db.Entry(user_information).State = EntityState.Modified; var userInfoQuery = from userInfo in db.User_Information where userInfo.Username == user_information.Username select userInfo; User_Information objUserInfo = userInfoQuery.FirstOrDefault(); objUserInfo.Name = user_information.Name; objUserInfo.Email = user_information.Email; objUserInfo.Gender = user_information.Gender; objUserInfo.Age = user_information.Age; objUserInfo.Address = user_information.Address; objUserInfo.Contact = user_information.Contact; objUserInfo.Blood_Group = user_information.Blood_Group; objUserInfo.Marital_Status = user_information.Marital_Status; objUserInfo.Salary = user_information.Salary; var userAccessQuery = from userAccess in db.User_Access where userAccess.Username == user_access.Username select userAccess; User_Access objUserAccess = userAccessQuery.FirstOrDefault(); objUserAccess.Password = user_access.Password; objUserAccess.Usertype = user_access.Usertype; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Username = new SelectList(db.User_Access, "Username", "Password", user_information.Username); return(View(user_information)); }
public ActionResult Profile_Edit(User_Information user_information, User_Access user_access) { if (ModelState.IsValid) { //db.Entry(user_access).State = EntityState.Modified; //db.Entry(user_information).State = EntityState.Modified; var userInfoQuery = from userInfo in db.User_Information where userInfo.Username == user_information.Username select userInfo; User_Information objUserInfo = userInfoQuery.FirstOrDefault(); objUserInfo.Name = user_information.Name; objUserInfo.Email = user_information.Email; objUserInfo.Address = user_information.Address; objUserInfo.Contact = user_information.Contact; var userAccessQuery = from userAccess in db.User_Access where userAccess.Username == user_access.Username select userAccess; User_Access objUserAccess = userAccessQuery.FirstOrDefault(); objUserAccess.Password = user_access.Password; db.SaveChanges(); return(RedirectToAction("Profile_Index", new { objUserInfo.ID })); } ViewBag.Username = new SelectList(db.User_Access, "Username", "Password", user_information.Username); return(View(user_information)); }
public ActionResult Create(UserViewModel model) { try { User_Access userAccess = new User_Access() { Username = model.Username, Password = model.Password, Usertype = model.Usertype }; User_Information userInfo = new User_Information(); userInfo.Name = model.Name; userInfo.Email = model.Email; userInfo.Gender = model.Gender; userInfo.Date_of_Birth = model.Date_of_Birth; userInfo.Age = model.Age; userInfo.Address = model.Address; userInfo.Contact = model.Contact; userInfo.Blood_Group = model.Blood_Group; userInfo.Marital_Status = model.Marital_Status; userInfo.Join_Date = model.Join_Date; userInfo.Salary = model.Salary; userInfo.Username = model.Username; userInfo.Name = model.Name; userInfo.User_Access = userAccess; db.User_Information.Add(userInfo); db.SaveChanges(); } catch (Exception ex) { throw ex; } return(RedirectToAction("Index", model)); //return View(model); }
public ActionResult Login(User_Access users) { if (ModelState.IsValid) { var details = from user in db.User_Access where user.Username == users.Username && user.Password == users.Password select user; if (details.FirstOrDefault() != null) { if (details.FirstOrDefault().Usertype == "Admin") { Session["Username"] = details.FirstOrDefault().Username; Session["Usertype"] = details.FirstOrDefault().Usertype; return(RedirectToAction("AdminDashboard", "Dashboard")); } else { Session["Username"] = details.FirstOrDefault().Username; Session["Usertype"] = details.FirstOrDefault().Usertype; return(RedirectToAction("StaffDashboard", "Dashboard")); } } else { ModelState.AddModelError("Error", "Wrong Username or Password"); } } else { ModelState.AddModelError("", "Invalid"); } return(View(users)); }
public Task <int> DeleteNoteAsync(User_Access note) { return(_database.DeleteAsync(note)); }