public bool CheckLogin(string username, string password) { var userService = new UserService(); var user = userService.GetUserByUserName(username); string encryptPw = FormsAuthentication.HashPasswordForStoringInConfigFile(password.Trim(), "sha1"); if (user != null && user.Password == encryptPw) return true; return false; }
public ActionResult SaleList() { var uService = new UserService(); var model = new SaleListModel { UserList = uService.GetAllUserWithDeActive() .Where(c => c.GroupId == (int)UserGroup.SALE && c.ReferUserId == AccessFactory.CurrentUser.Id) }; return View(model); }
public static void Login(string username) { var service = new UserService(); var user = service.GetUserByUserName(username); Session[Constant.UserLogined] = user; }
public ActionResult UpdateSaleStatus() { try { string name = Request["Name"]; string status = Request["Status"]; var uService = new UserService(); var user = uService.GetUserByUserName(name); if (user != null) { if (status == Status.ACTIVE.ToString()) user.Status = (int)Status.ACTIVE; else user.Status = (int)Status.DEACTIVE; uService.UpdateUser(user); } return Json(new { finish = true }); } catch (Exception) { return Json(new { finish = false }); } }
private CustomerListModel initCustomerListModel(int selectedUser = Constant.ALL_VALUE, int seletedStatus = Constant.ALL_VALUE, string searchKey = "") { var model = new CustomerListModel(); var uService = new UserService(); var cService = new CustomerService(); var sellers = uService.GetAllUser().Where(c => c.ReferUserId == AccessFactory.CurrentUser.Id).ToList(); sellers.Insert(0, new User() { Id = Constant.ALL_VALUE, Name = Constant.ALL }); model.Sellers = sellers; var statuses = cService.GetAllCustomerStatus(); statuses.Insert(0, new CustomerStatus() { Name = Constant.ALL, Type = Constant.ALL_VALUE }); model.Status = statuses; var allcustomer = new List<Customer>(); var sellersfilter = sellers; if (selectedUser != Constant.ALL_VALUE) sellersfilter = sellersfilter.Where(c => c.Id == selectedUser).ToList(); searchKey = searchKey != null ? searchKey.Trim().ToLower() : ""; foreach (var seller in sellersfilter) { allcustomer.AddRange(cService.GetAllCustomer().Where(c => c.ReferUserId == seller.Id).ToList()); } if (seletedStatus != Constant.ALL_VALUE) allcustomer = allcustomer.Where(c => c.Status == seletedStatus).ToList(); if (searchKey != "") //allcustomer = (from c in allcustomer // where c.Name.ToLower().Contains(searchKey) // select c).OrderBy(c => c.Name).ToList(); allcustomer = allcustomer.Where(c => (c.Name != null && c.Name.ToLower().Contains(searchKey)) || (c.PhoneNumber1 != null && c.PhoneNumber1.ToLower().Contains(searchKey)) || (c.PhoneNumber2 != null && c.PhoneNumber2.ToLower().Contains(searchKey)) || (c.Email != null && c.Email.Contains(searchKey)) ).ToList(); model.Customers = allcustomer; model.SelectedSeller = Constant.ALL_VALUE; model.SelectedCustomerStatus = Constant.ALL_VALUE; model.Search = ""; return model; }