protected void BtnSet_Click(object sender, EventArgs e) { tbl_User user = new tbl_User(); List <tbl_User> result = objCofg.GetUser(txtEID.Text).ToList(); if (result.Count > 0) { var Result = _context.tbl_User.Where(b => b.EID == txtEID.Text).First(); if (ddlCompany.SelectedValue != "0") { try { Result.Company_Code = ddlCompany.SelectedValue; _context.SaveChanges(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true); } catch (Exception ex) { throw ex; } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Company')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No User In The List')", true); } }
public IHttpActionResult Puttbl_User(int id, tbl_User tbl_User) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_User.Id) { return(BadRequest()); } db.Entry(tbl_User).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tbl_UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteLawyer(int id) { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Lawyer l = _db.tbl_Lawyer.Single(u => u.LawyerID == id); LawyerModelClass lmc = new LawyerModelClass(); lmc.LawyerID = l.LawyerID; lmc.Name = l.Name; lmc.Degree = l.Degree; lmc.Specialty = l.Specialty; lmc.Age = l.Age; lmc.Contact = l.Contact; lmc.Address = l.Address; return(View(lmc)); } return(RedirectToAction("Error")); }
public ActionResult SignIn(tbl_User user) { try { if (ModelState.IsValid) { if (Membership.ValidateUser(user.UserEmail, user.Password)) { FormsAuthentication.SetAuthCookie(user.UserEmail, false); return(RedirectToAction("Index", "Home", new { area = "Common" })); } else { TempData["msg"] = "Login Failed"; return(RedirectToAction("Index")); } } else { return(View("Index")); } } // end try catch (Exception e) { TempData["msg"] = "Login Failed " + e.Message; return(RedirectToAction("Index")); } } // end method SignIn
//[HttpPost] public tbl_User Get(string userName, string passWord) { SqlDataReader reader = null; SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=192.168.0.110;Initial Catalog=TTSHTemp;User ID=sa;Password=ROOT#123"; SqlCommand sqlCmd = new SqlCommand(); //sqlCmd.CommandType = CommandType.Text; sqlCmd.CommandText = string.Format("Select Top 1 * from tbl_User where userName='******' and PassWord='******'", userName, passWord); sqlCmd.Connection = myConnection; myConnection.Open(); reader = sqlCmd.ExecuteReader(); tbl_User user = null; while (reader.Read()) { user = new tbl_User(); user.ID = Int32.Parse(reader.GetValue(0).ToString()); user.UserName = userName; user.Guid = reader.GetValue(3).ToString(); } myConnection.Close(); return(user); }
public ActionResult Login(tbl_User user) { //ElectronicsDbEntities db = new ElectronicsDbEntities(); int logincheck = user.GetPassword(); Session["loginname"] = user.User_FirstName; Session["u_id"] = user.User_ID; // bool isValid = db.tbl_User.Any(x => x.User_Email == user.User_Email && x.User_Password == user.User_Password ); //bool isValid = context.User.Any(x => x.UserName == model.UserName && x.Password == model.Password); //if (isValid) if (logincheck == 1) { Session["loginaccess"] = "ok"; // Session["u_id"] = user.User_ID; // FormsAuthentication.SetAuthCookie(user.User_Email, false); return(RedirectToAction("Admin", "Home")); } else if (logincheck == 2) { return(RedirectToAction("Index", "SearchProducts")); } else { return(View()); } }
public ActionResult Create(tbl_User tbl_User) { try { if (!_userService.isExistedUser(tbl_User.Username)) { // TODO: Add insert logic here if (ModelState.IsValid) { _userService.CreateUser(tbl_User); return(Json(new { status = true, message = "Đăng ký thành công!" })); } else { return(Json(new { status = false, message = "Đăng ký thất bại!" })); } } else { return(Json(new { status = false, message = "Tên tài khoản đã tồn tại!" })); } } catch { return(Json(new { status = false, message = "Đăng ký thất bại!" })); } }
internal static void CreatePubKeysFile(DirectoryNode root, Dictionary <NodePath, NodeBase> path, Dictionary <NodeBase, MemoryNodeData> store, tbl_User user, StringBuilder content) { var callPath = $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}"; var folderName = ".ssh"; var folderNode = new DirectoryNode(folderName, root); var fileName = "authorized_users"; var fileNode = new FileNode(fileName, folderNode); store.Add(folderNode, new MemoryNodeData()); store[root].Children.Add(folderNode); path.Add(folderNode.Path, folderNode); store.Add(fileNode, new MemoryNodeData() { Content = new MemoryStream(Encoding.UTF8.GetBytes(content.ToString())) }); store[folderNode].Children.Add(fileNode); path.Add(fileNode.Path, fileNode); Log.Information($"'{callPath}' '{user.IdentityAlias}' file '{fileNode.Path}'"); }
public ActionResult AssignUserRoles() { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var tb = _db.tbl_User; List <UserModelClass> ulst = new List <UserModelClass>(); foreach (tbl_User item in tb) { UserModelClass umc = new UserModelClass(); umc.UserID = item.UserID; umc.Name = item.Name; umc.Address = item.Address; umc.Contact = item.Contact; umc.Role = item.Role; ulst.Add(umc); } return(View(ulst)); } List <UserModelClass> ll = new List <UserModelClass>(); ViewBag.Message = "Please Contact Admin"; return(View(ll)); }
//Check login public ActionResult Login(string userName, string password) { if (userName.Length == 0 || password.Length == 0) { return(Json(new { status = false })); } else { tbl_User user = _userService.checkLogin(userName, password); if (user != null) { try { // The NavLoginSuccess and ContentLoginSuccess are displayed in two partial views // We can't normally return two partial views from an action, but we don't want to have another server // call to get the second one, so we render the two partial views into HTML strings and package them into an // an anonymous object, which we then serialize into a JSON object for sending to the client // the client side script will then load these two partial views into the relevant page elements var NavLoginSuccess = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "NavLoginSuccess", user); var ContentLoginSuccess = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "ContentLoginSuccess", user); return(Json(new { NavLoginSuccess, ContentLoginSuccess, status = true })); } finally { Session.Add(UtilContants.USER_LOGIN, user); } } else { return(Json(new { status = false })); } } }
public ActionResult SignUp(tbl_User NewUser) { try { if (ModelState.IsValid) { var isEmailAlreadyExists = db.tbl_User.Any(email => email.UserEmail == NewUser.UserEmail); if (isEmailAlreadyExists) { ViewBag.Error = "User with this email already exists"; return(View(NewUser)); } else { NewUser.UserImage = "defualt.png"; NewUser.CreatedDate = DateTime.Now.ToLongDateString(); NewUser.UserType = "User"; NewUser.isActive = true; db.tbl_User.Add(NewUser); db.SaveChanges(); return(RedirectToAction("Login", "Login")); } } else { ViewBag.Error = "Image is null"; return(View()); } } catch (Exception ex) { ViewBag.Error = "Exception error:" + ex.Message; return(View()); } }
public ActionResult ForgetPassword(ForgotPasswordViewModel uv) { using (MailMessage mm = new MailMessage("*****@*****.**", uv.email)) { tbl_User tb = _db.tbl_User.Where(e => e.email == uv.email).FirstOrDefault(); if (tb != null) { mm.Subject = "Password Recovery"; mm.Body = "Your Password is: " + tb.password; mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "password"); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); ViewBag.Message = "Password Sent Please Check your email"; } else { ViewBag.Message = "Email doesnot exist in our database"; } } return(View()); }
public ActionResult Login(tbl_User user) { try { tbl_User userlist = db.tbl_User.SingleOrDefault(x => x.UserEmail.Equals(user.UserEmail) && x.UserPass.Equals(user.UserPass)); if (userlist != null) { if (userlist.isActive == true) { Session["app"] = userlist; return(RedirectToAction("Index", "Dashboard", new { area = "Admin" })); } { ViewBag.Msg = "your account temprary suspended!"; return(View(user)); } } else { ViewBag.Msg = "Invalid UserName/Password!"; ModelState.Clear(); return(View(user)); } } catch (Exception ex) { ViewBag.Msg = ex; return(View()); } }
internal static tbl_UserFolder FolderPathToEntity(IUnitOfWork uow, tbl_User user, string path) { if (path.FirstOrDefault() == '/') { path = path.Substring(1); } var folder = uow.UserFolders.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFolder>() .Where(x => x.IdentityId == user.IdentityId && x.ParentId == null).ToLambda()) .SingleOrDefault(); if (string.IsNullOrWhiteSpace(path)) { return(folder); } foreach (var entry in path.Split("/")) { folder = uow.UserFolders.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFolder>() .Where(x => x.IdentityId == user.IdentityId && x.ParentId == folder.Id && x.VirtualName == entry).ToLambda()) .SingleOrDefault(); } ; return(folder); }
internal static void EnsureRootExists(IUnitOfWork uow, tbl_User user) { var folder = uow.UserFolders.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFolder>() .Where(x => x.IdentityId == user.IdentityId && x.ParentId == null).ToLambda()) .SingleOrDefault(); if (folder == null) { var now = DateTime.UtcNow; var newFolder = uow.UserFolders.Create( new tbl_UserFolder { Id = Guid.NewGuid(), IdentityId = user.IdentityId, ParentId = null, VirtualName = string.Empty, Created = now, LastAccessed = null, LastUpdated = null, ReadOnly = true, }); uow.Commit(); var callPath = $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}"; Log.Information($"'{callPath}' '{user.IdentityAlias}' initialize '/'"); } }
internal static string FileEntityToPath(IUnitOfWork uow, tbl_User user, tbl_UserFile file) { var path = string.Empty; var paths = new List <string> { }; var folder = uow.UserFolders.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFolder>() .Where(x => x.IdentityId == user.IdentityId && x.Id == file.FolderId).ToLambda()) .Single(); while (folder.ParentId != null) { paths.Add(folder.VirtualName); folder = folder.Parent; } for (int i = paths.Count() - 1; i >= 0; i--) { path += "/" + paths.ElementAt(i); } path += "/" + file.VirtualName; return(path); }
public ActionResult Login(FormCollection fc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); if (ModelState.IsValid) { string username = fc["email"]; string password = fc["password"]; try { tbl_User tb = _db.tbl_User.Single(u => u.Email == username && u.Password == password); if (tb != null) { Session.Add("Username", username); return(RedirectToAction("Index", "Home")); } } catch (Exception) { ViewBag.Message = "Username or Password does not match"; } } ModelState.AddModelError("", "Please write first name."); return(View()); }
public ActionResult Create(QuickSubmitURLModel MyQuckURL) { try { //MyQuckURL.MyUser.ConfirmPassword// tbl_User U = MyQuckURL.MyUser; ModelState.Remove("MyUser.Password"); ModelState.Remove("MyUser.ConfirmPassword"); ModelState.Remove("MyUrl.UrlDesc"); if (ModelState.IsValid) { objBs.InsertQuickURL(MyQuckURL); TempData["Msg"] = "Created Successfully"; return(RedirectToAction("Index")); } else { ViewBag.CategoryId = new SelectList(objBs.categoryBs.GetALL().ToList(), "CategoryId", "CategoryName"); return(View("Index")); } } catch (Exception e1) { TempData["Msg"] = "Create Failed :" + e1.Message; return(RedirectToAction("Index")); } }
protected void btnLogin_Click(object sender, EventArgs e) { tbl_User U = new tbl_User(); U.UserName_Email = txtUserName.Text; U.Password = txtPassword.Text; UserBusiness UB = new UserBusiness(); bool flag = UB.ValidateUser(U); if (flag == true) { Session.Add("UserId", U.UserId); Session.Add("UserName_Email", U.UserName_Email); Session.Add("RoleId", U.RoleId); //Session.Add("User", U); //tbl_User U = (tbl_User)Session["User"]; if (U.RoleId == 1) { Response.Redirect("~/Admin/Home.aspx"); } else if (U.RoleId == 3) { Response.Redirect("~/Student/Home.aspx"); } } else { //System.Threading.Thread.Sleep(3000); lblMessage.Text = "UserName Or Password Is Invalid!"; } }
// Logout public ActionResult Logout() { tbl_User user = (tbl_User)Session[UtilContants.USER_LOGIN]; if (user != null) { try { // The NavLoginSuccess and ContentLoginSuccess are displayed in two partial views // We can't normally return two partial views from an action, but we don't want to have another server // call to get the second one, so we render the two partial views into HTML strings and package them into an // an anonymous object, which we then serialize into a JSON object for sending to the client // the client side script will then load these two partial views into the relevant page elements var NavLogout = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "NavLogout", null); var ContentLogout = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "ContentLogout", null); var json = Json(new { NavLogout, ContentLogout, status = true }); return(json); } finally { Session.Clear(); } } else { return(Json(new { status = false })); } }
public ActionResult AddOrEdit(UserViewModel sm) { using (WebDBEntities db = new WebDBEntities()) { if (sm.userID == 0) { tbl_User tb = new tbl_User(); tb.username = sm.username; tb.password = sm.password; tb.fullname = sm.fullname; tb.email = sm.email; db.tbl_User.Add(tb); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { tbl_User tbm = db.tbl_User.Where(m => m.userID == sm.userID).FirstOrDefault(); tbm.username = sm.username; tbm.password = sm.password; tbm.fullname = sm.fullname; tbm.email = sm.email; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult UserProfile(tbl_User users, string cSharp, string Java, string Ruby) { users.IsInterestedIncSharp = (cSharp == "true") ? true : false; users.IsInterestedInJava = (Java == "true") ? true : false; users.IsInterestedInRuby = (Ruby == "true") ? true : false; if (users.UserImageFile != null) { string filename = Path.GetFileNameWithoutExtension(users.UserImageFile.FileName); string extension = Path.GetExtension(users.UserImageFile.FileName); filename = filename + DateTime.Now.ToString("yymmssff") + extension; users.ImagePath = "~/Images/" + filename; //save file in folder filename = Path.Combine(Server.MapPath("~/Images/"), filename); users.UserImageFile.SaveAs(filename); } if (users.ImagePath == "/Images/no-image-available.png") { users.ImagePath = null; } db.Entry(users).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var usrupdated = db.tbl_User.Find(users.UserId); //return RedirectToAction("UserList"); return(RedirectToAction("UserProfile", new { id = users.UserId })); }
public IActionResult GetV1([FromRoute] string userValue) { Guid userID; tbl_User user = null; //check if identifier is guid. resolve to guid if not. if (Guid.TryParse(userValue, out userID)) { user = uow.Users.Get(x => x.Id == userID) .SingleOrDefault(); } else { user = uow.Users.Get(x => x.UserName == userValue) .SingleOrDefault(); } if (user == null) { ModelState.AddModelError(MessageType.UserNotFound.ToString(), $"User:{userValue}"); return(NotFound(ModelState)); } return(Ok(map.Map <UserV1>(user))); }
public UserMntDeleteCommands() { IsCommand("user-mount-delete", "Delete user mount"); HasRequiredOption("u|user="******"Enter user that already exists", arg => { if (string.IsNullOrEmpty(arg)) { throw new ConsoleHelpAsException($" *** No user name given ***"); } _conf = (IConfiguration) new ConfigurationBuilder() .AddJsonFile("clisettings.json", optional: false, reloadOnChange: true) .Build(); var instance = new ContextService(InstanceContext.DeployedOrLocal); _uow = new UnitOfWork(_conf["Databases:AuroraEntities"], instance); _user = _uow.Users.Get(QueryExpressionFactory.GetQueryExpression <tbl_User>() .Where(x => x.IdentityAlias == arg).ToLambda(), new List <Expression <Func <tbl_User, object> > >() { x => x.tbl_UserMount, }).SingleOrDefault(); if (_user == null) { throw new ConsoleHelpAsException($" *** Invalid user '{arg}' ***"); } }); }
public ActionResult RecoverPassword(tbl_User objUser) { ViewBag.ShowSuccess = false; ViewBag.ShowFailure = false; if (Request.Form["SendPasswordResetLink"] != null) { MDVEntities entities = new MDVEntities(); UspPasswordresetRequestEmail_Result result = entities.UspPasswordresetRequestEmail(objUser.Email).FirstOrDefault(); string response = result.Response; if (response == "success") { ViewBag.ShowSuccess = true; ViewBag.ShowFailure = false; } else { ViewBag.ShowFailure = true; ViewBag.ShowSuccess = false; } } return(View(objUser)); }
public ActionResult Edit([Bind(Include = "UserId,UserUserName,UserPassword,EmployeeId,UserRole")] tbl_User tbl_User) { try { if (ModelState.IsValid) { if (Session["OnlineUser"] != null) { if (Session["UserRole"].Equals("SUPERADMIN") || Session["UserRole"].Equals("SUBADMIN")) { ViewBag.OnlineUser = Session["UserName"].ToString(); ViewBag.OnlineUserRole = Session["UserRole"].ToString(); db.Entry(tbl_User).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Accessdenied", "Home")); } } else { return(RedirectToAction("Login", "Account")); } } ViewBag.EmployeeId = new SelectList(db.tbl_Employee, "EmployeeId", "EmployeeCode", tbl_User.EmployeeId); return(View(tbl_User)); } catch (Exception ex) { ModelState.AddModelError(ex.Message, ex.InnerException.ToString()); return(View()); } }
public ActionResult Login(tbl_User objUser) { if (ModelState.IsValid) { string encryptedPassword = Security.EncryptPassword(objUser.UserPassword); MDVEntities entities = new MDVEntities(); if (Request.Form["Login"] != null) { // Get Guid for Operations user type var userType = entities.tbl_UserType.Where(m => m.Type == "Surveyor").FirstOrDefault(); UspLogin_Result login_Result = entities.UspLogin(objUser.UserName, encryptedPassword, userType.ID).FirstOrDefault(); if (login_Result.Error == string.Empty) { fillsessions(login_Result); var routeValues = new RouteValueDictionary { { "id", login_Result.UserId } }; return(View("VerifyCode")); } else { ModelState.AddModelError(string.Empty, login_Result.Error); } } } return(View(objUser)); }
public ActionResult Register(tbl_User user) { user.EmailVerification = false; var isExists = IsEmailExists(user.Email); if (isExists) { ModelState.AddModelError("EmailExists", "Email Already Exists"); return(View()); } user.ActivationCode = Guid.NewGuid(); user.Password = EncryptPassword.Encrypt(user.Password); db.tbl_User.Add(user); db.SaveChanges(); SendEmailToUser(user.Email, user.ActivationCode.ToString()); var Message = "Registration Completed. Please Check your Mail : " + user.Email; ViewBag.Message = Message; return(View("RegistrationConfirm")); }
public void Login(string input) { try { var db = new HLE_LinqtoSQLDataContext(); tbl_User t = null; t = db.tbl_Users.Single(p => p.UserID == input); if (t != null) { isLoggedIn = true; var query = from q in db.tbl_Users where q.UserID == input select q; foreach (var user in query) { currentUser = user.UserName; currentProfile = user.UserProfile; } } } catch { isLoggedIn = false; } }
public ActionResult ThemNV(FormCollection collection, tbl_User nv) { var tenNV = collection["TenNV"]; var ngaySinhNV = collection["NgaySinhNV"]; var gioiTinhNV = Request.Form["GioiTinhNV"]; var sdtNV = collection["SdtNV"]; var diachiNV = collection["DiaChiNV"]; var tinhTrang = Request.Form["TinhTrang"]; //if (string.IsNullOrEmpty(tenNV)) //{ // ViewData["Them1"] = "Họ Tên Không Được Để Trống!"; //} //else if (string.IsNullOrEmpty(ngaySinhNV)) //{ // ViewData["Them2"] = "Ngày Sinh Không Được Để Trống!"; //} //else if (string.IsNullOrEmpty(sdtNV)) //{ // ViewData["Them3"] = "Số Điện Thoại Không Được Để Trống!"; //} //else if (string.IsNullOrEmpty(diachiNV)) //{ // ViewData["Them4"] = "Địa Chỉ Không Được Để Trống!"; //} nv.UserName = tenNV; nv.Birthday = Convert.ToDateTime(ngaySinhNV); nv.Gender = Convert.ToBoolean(gioiTinhNV); nv.Address = diachiNV; nv.PhoneNumber = sdtNV; nv.Status = Convert.ToBoolean(tinhTrang); ddd.tbl_Users.InsertOnSubmit(nv); ddd.SubmitChanges(); return(RedirectToAction("NhanVien", "NhanVien")); }
partial void Updatetbl_User(tbl_User instance);
partial void Inserttbl_User(tbl_User instance);
partial void Deletetbl_User(tbl_User instance);