public ActionResult InsertStaff(SA_User entity, int count) { string quHao = _xinZhengQuYuService.GetByAreaName(entity.City).QuHao;//).QuHao; string city = GetOrganizationAreaPath().Substring(GetOrganizationAreaPath().LastIndexOf("/") + 1); if (ModelState.IsValid) { for (int i = 0; i < count; i++) { entity.CreatedBy = GetCurrentUserName(); entity.CreatedDate = DateTime.Today; string xuLieHao = quHao + RandomNumber.GetRnd(5, true, true, false, false); entity.Account = xuLieHao; entity.Name = xuLieHao; entity.City = city; entity.Password = entity.Password ?? "123456"; _service.AddUser(entity); _service.Save(); } var parentNode = this.GetCmp <TreePanel>("treePanelSAOrganization").GetNodeById(entity.MainOrgId); parentNode.Set("leaf", false); parentNode.Reload(); parentNode.ExpandChildren(true); this.GetCmp <Window>("windowSA_User").Hide(); //this.GetCmp<Window>("windowSA_Organization").Hide(); //this.GetCmp<Store>("storeSAOrganization").Reload(); return(this.Direct()); } return(this.Direct()); }
public ActionResult UpdateStaff(SA_User entity) { if (ModelState.IsValid) { entity.LastModifiedBy = GetCurrentUserName(); entity.LastModifiedDate = DateTime.Now; var org = new SA_Organization(); entity.Account = entity.Name; org = _service.GetOrgContainsId(entity.Id); org.Name = entity.Name; org.Description = entity.Name; org.Code = entity.Name; _service.UpdateOrganization(org); _service.UpdateUser(entity); _service.Save(); var window = this.GetCmp <Window>("windowSA_User"); window.Hide(); TreePanel treePanel = this.GetCmp <TreePanel>("treePanelSAOrganization"); treePanel.GetNodeById(entity.MainOrgId).Reload(); return(this.Direct()); } return(this.Direct()); }
public ActionResult EditUser(int id) { ChemAnalystContext _context = new ChemAnalystContext(); UserDataStore Obj = new UserDataStore(); SA_User obj = Obj.GetUserByid(id); SA_UserViewModel Objuser = new SA_UserViewModel(); Objuser.id = obj.id; Objuser.Fname = obj.Fname; Objuser.Lname = obj.Lname; Objuser.Phone = obj.Phone; Objuser.ProfileImage = obj.ProfileImage; Objuser.Role = obj.Role; Objuser.Email = obj.Email; Objuser.UserPassword = obj.UserPassword; Objuser.Gender = obj.Gender; var customerData = (from User in _context.SA_Role // select { Fname = User.Fname+" "+User.Lname , Phone = User.Phone, Role=User.Role,Email=User.Email,UserPassword=User.Password}); select new SelectListItem { Text = User.Role, Value = User.Role }).ToList(); Objuser.UserRoleList = customerData; return(View("add-user", Objuser)); }
public ActionResult SaveProfile(SA_User User) { for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/images"), fileName); file.SaveAs(path); User.ProfileImage = fileName; } } UserDataStore Obj = new UserDataStore(); Obj.UpdateUser(User); if ((User.Role).ToUpper() != "ADMIN") { return(View("UserView")); } return(RedirectToAction("ShowUserList", "Admin")); }
public ActionResult UpdatePassword(FormCollection ChangePassword) { int LoginUser = int.Parse(ChangePassword["LoginUser"]); string CurPassword = ChangePassword["CurPassword"]; string newPassword = ChangePassword["newPassword"]; string confirmpasswd = ChangePassword["confirmpasswd"]; UserDataStore ObjUser = new UserDataStore(); SA_User loginUser = ObjUser.GetUserByid(LoginUser); if ((loginUser != null)) { if (loginUser.UserPassword == CurPassword) { loginUser.id = LoginUser; loginUser.UserPassword = newPassword; int valid = ObjUser.UpdatePassword(loginUser); if (valid > 0) { ViewBag.Message = "Password Updated Successfuly."; } else { ViewBag.Message = "Password not Updated Successfuly."; } } else { ViewBag.Message = "Your current Password is not matched."; } } return(View("changePassword")); }
public async Task <bool> UpdateUser(SA_User User) { try { // Category.CreatedDate = DateTime.Now; SA_User Objuser = _context.SA_User.Where(user => user.id == User.id).FirstOrDefault(); Objuser.Fname = User.Fname; Objuser.Lname = User.Lname; Objuser.Phone = User.Phone; Objuser.Role = User.Role; Objuser.Email = User.Email; Objuser.Gender = User.Gender; Objuser.UserPassword = User.UserPassword; if (User.ProfileImage != null) { Objuser.ProfileImage = User.ProfileImage; } //if (Objuser.ProfileImage != null) // Objuser.ProfileImage = User.ProfileImage; _context.Entry(Objuser).State = EntityState.Modified; int x = _context.SaveChanges(); return(x == 0 ? false : true); } catch (Exception ex) { return(false); throw; } }
public async Task <bool> UpdateUser(SA_User User) { _context.Entry(User).State = EntityState.Modified; // User.ModeifiedDate = DateTime.Now; int x = await _context.SaveChangesAsync(); return(x == 0 ? false : true); }
public async Task <bool> AddUser(SA_User User) { // User.CreatedDate = DateTime.Now; _context.SA_User.Add(User); int x = await _context.SaveChangesAsync(); return(x == 0 ? false : true); }
internal bool DeleteUser(int id) { SA_User User = _context.SA_User.Where(user => user.id == id).FirstOrDefault(); _context.Entry(User).State = EntityState.Deleted; int x = _context.SaveChanges(); return(x == 0 ? false : true); }
internal int UpdatePassword(SA_User ObjPassChange) { SA_User UpdatedPass = _context.SA_User.Where(user => user.id == ObjPassChange.id).FirstOrDefault(); UpdatedPass.UserPassword = ObjPassChange.UserPassword; _context.Entry(UpdatedPass).State = EntityState.Modified; int x = _context.SaveChanges(); return(x); }
public bool UpdateUserStatus(int userId) { SA_User Objuser = _context.SA_User.Where(user => user.id == userId).FirstOrDefault(); if (Objuser.Status) { Objuser.Status = false; } else { Objuser.Status = true; } _context.Entry(Objuser).State = EntityState.Modified; int x = _context.SaveChanges(); return(x == 0 ? false : true); }
public ActionResult Login(UserModel userModel) { var securityService = new SecurityService(); var user = new SA_User { Name = userModel.Name, Password = userModel.Password }; var authenticatedUser = securityService.GetUser(user); if (authenticatedUser != null) { Response.SetAuthCookie(authenticatedUser.Name, false, //authenticatedUser.Id); string.Format("{0}{1}", authenticatedUser.Id, "|true")); return(RedirectToAction("Index", "TianYuanDataCenter")); //"ZhiDiZhuZhaiSearch");//TianYuanDataCenter } return(View()); }
public ActionResult UpdateProfile() { int id = int.Parse(Session["LoginUser"].ToString()); ChemAnalystContext _context = new ChemAnalystContext(); UserDataStore Obj = new UserDataStore(); SA_User obj = Obj.GetUserByid(id); SA_UserViewModel Objuser = new SA_UserViewModel(); Objuser.id = obj.id; Objuser.Fname = obj.Fname; Objuser.Lname = obj.Lname; Objuser.Phone = obj.Phone; Objuser.Role = obj.Role; Objuser.Email = obj.Email; Objuser.Gender = obj.Gender; var customerData = (from User in _context.SA_Role // select { Fname = User.Fname+" "+User.Lname , Phone = User.Phone, Role=User.Role,Email=User.Email,UserPassword=User.Password}); select new SelectListItem { Text = User.Role, Value = User.Role }).ToList(); Objuser.UserRoleList = customerData; return(View("update-profile", Objuser)); }
public SA_User CheckUser(SA_User Login) { //return _context.SA_User.Where(x => x.Email == Login.Email && x.UserPassword == Login.UserPassword && x.Status==true).SingleOrDefault(); return(_context.SA_User.Where(x => x.Email == Login.Email && x.UserPassword == Login.UserPassword).SingleOrDefault()); }
/// <summary> /// get user data /// </summary> /// <param name="collection"></param> /// <returns></returns> public ActionResult UserLogin(FormCollection collection) { SA_User login = new Models.SA_User(); login.Email = Request["Username"]; LoginDataStore LoginStore = new LoginDataStore(); login.UserPassword = Request["Password"]; if ((login.Email == "customer" && login.UserPassword == "Customer")) { string product = null; string ChartType = null; string Range = null; string CompareProject = null; bool Customer = true; return(RedirectToAction("ChecmPriceYearlyChart", "ChemicalPricing", new { product, ChartType, Range, CompareProject, Customer })); // return this.RedirectToAction("ChecmPriceYearlyChart", "ChemicalPricing"); } if ((LoginStore.CheckUser(login) != null) || (login.Email == "admin" && login.UserPassword == "admin")) { SA_User objectuser = LoginStore.CheckUser(login); if (objectuser.Status == false) { TempData["ErrorMessage"] = "You don’t have access to the account. Kindly contact Administrator."; return(View("Login")); } if ((objectuser != null)) { Session["LoginUser"] = objectuser.id; Session["User"] = objectuser.Fname + " " + objectuser.Lname; Session["UserImg"] = "images /" + objectuser.ProfileImage;; Session["UserRole"] = objectuser.Role; List <SA_RoleWiseAccess> Access = LoginStore.Getpage(objectuser.Role); Session["Access"] = Access; if (objectuser.Role == "Sales") { return(this.RedirectToAction("ShowSubscriptionListForSales", "SubsManagement")); } if (objectuser.Role.ToUpper() != "ADMIN") { return(this.RedirectToAction("Index", "User")); } } else { objectuser = new SA_User(); Session["LoginUser"] = 100001; objectuser.Role = "Admin"; Session["UserRole"] = objectuser.Role; List <SA_RoleWiseAccess> Access = LoginStore.Getpage(objectuser.Role); Session["Access"] = Access; Session["User"] = "******"; Session["UserImg"] = "images/" + "user.jpg"; } return(RedirectToAction("ShowUserList")); } else { return(View("Login")); } }