public ActionResult CLientList(int?page, int?rows) { var pageNo = page ?? 1; var numOfRows = rows ?? 5; var clients = clientRepository.GetAll(); var userLogins = userLoginRepository.GetAll(); var query = from userLogin in userLogins join client in clients on userLogin.Id equals client.FakeId select new ClientUserLoginModel { Id = client.FakeId, Name = client.Name, Phone = userLogin.Phone, Email = userLogin.Email, City = client.City.Name, Area = client.Area.Name }; return(View(query.ToList().ToPagedList(pageNo, numOfRows))); }
public ActionResult EmployeeList(int?page, int?rows) { var pageNo = page ?? 1; var numOfRows = rows ?? 5; var employees = employeeRepository.GetAll(); var userLogins = userLoginRepository.GetAll(); var query = from userLogin in userLogins join employee in employees on userLogin.Id equals employee.FakeId select new EmployeeUserLoginModel { Id = employee.FakeId, Name = employee.Name, Phone = userLogin.Phone, Email = userLogin.Email, Salary = employee.Salary, Commission = employee.Commission }; return(View(query.ToList().ToPagedList(pageNo, numOfRows))); }
public ActionResult LabourList(int?page, int?rows) { var pageNo = page ?? 1; var numOfRows = rows ?? 5; var labours = labourRepository.GetAll(); var userLogins = userLoginRepository.GetAll(); var query = from userLogin in userLogins join labour in labours on userLogin.Id equals labour.FakeId select new LabourUserLoginModel { Id = labour.FakeId, Name = labour.Name, Phone = userLogin.Phone, Email = userLogin.Email, Wallet = labour.Wallet, City = labour.City.Name, Area = labour.Area.Name }; return(View(query.ToList().ToPagedList(pageNo, numOfRows))); }
/*Area-List Search*/ /*Client-List Search*/ public JsonResult SearchClientList(string searchBy, string searchValue, int?page, int?rows) { var pageNo = page ?? 1; var numOfRows = rows ?? 5; List <Client> clientList = clientRepository.GetAll().ToList(); List <UserLogin> userLogins = userLoginRepository.GetAll().ToList(); switch (searchBy) { case "phone": //search by phone userLogins = userLogins.Where(u => u.Phone.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList(); break; case "email": //search by email userLogins = userLogins.Where(u => u.Email.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList(); break; case "city": //search by city clientList = clientList.Where(c => c.City.Name.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList(); break; case "area": //search by area clientList = clientList.Where(c => c.Area.Name.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList(); break; case "id": //search by id clientList = clientList.Where(c => c.FakeId.ToString().ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList(); break; default: //by default, search by name clientList = clientList.Where(c => c.Name.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList(); break; } IEnumerable <ClientUserLoginModel> clientUserLoginModel; if (searchBy.Equals("phone") | searchBy.Equals("email")) { clientUserLoginModel = from userLogin in userLogins join client in clientList on userLogin.Id equals client.FakeId select new ClientUserLoginModel { Id = client.FakeId, Name = client.Name, City = client.City.Name, Area = client.Area.Name, Phone = userLogin.Phone, Email = userLogin.Email }; } else { clientUserLoginModel = from client in clientList join userLogin in userLogins on client.FakeId equals userLogin.Id select new ClientUserLoginModel { Id = client.FakeId, Name = client.Name, City = client.City.Name, Area = client.Area.Name, Phone = userLogin.Phone, Email = userLogin.Email }; } return(Json(clientUserLoginModel, JsonRequestBehavior.AllowGet)); // .ToPagedList(pageNo, numOfRows) }
public ActionResult LogInSubmit(LoginFormViewModel viewModel) { var user = userLoginRepository.GetAll().FirstOrDefault(u => u.Email.Equals(viewModel.UserLogin.Email) && u.Password.Equals(viewModel.UserLogin.Password)); if (user != null) { // store cookie for 1 day HttpCookie loginIdCookie = new HttpCookie("LoginId"); loginIdCookie.Expires = DateTime.Now.AddDays(1d); loginIdCookie.Value = user.Id.ToString(); Response.Cookies.Add(loginIdCookie); HttpCookie loginTypeCookie = new HttpCookie("LoginType"); loginTypeCookie.Expires = DateTime.Now.AddDays(1d); loginTypeCookie.Value = user.UserType.ToString(); Response.Cookies.Add(loginTypeCookie); if (viewModel.RememberMe) { // store cookie for 1 day HttpCookie loginEmailCookie = new HttpCookie("LoginEmail"); loginEmailCookie.Expires = DateTime.Now.AddDays(1d); loginEmailCookie.Value = user.Email; Response.Cookies.Add(loginEmailCookie); HttpCookie loginPasswordCookie = new HttpCookie("LoginPassword"); loginPasswordCookie.Expires = DateTime.Now.AddDays(1d); loginPasswordCookie.Value = user.Password; Response.Cookies.Add(loginPasswordCookie); } else { // delete cookie if (Request.Cookies["LoginEmail"] != null) { HttpCookie loginEmailCookie = Request.Cookies["LoginEmail"]; loginEmailCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(loginEmailCookie); HttpCookie loginPasswordCookie = Request.Cookies["LoginPassword"]; loginPasswordCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(loginPasswordCookie); } } switch (user.UserType) { case UserType.Client: // logged in user is client HttpCookie loginNameCookie = new HttpCookie("LoginName"); loginNameCookie.Expires = DateTime.Now.AddDays(1d); loginNameCookie.Value = clientRepository.Get(user.Id).Name; Response.Cookies.Add(loginNameCookie); return(RedirectToAction("Index", "Client")); case UserType.Employee: // logged in user is employee HttpCookie loginEmpNameCookie = new HttpCookie("LoginName"); loginEmpNameCookie.Expires = DateTime.Now.AddDays(1d); loginEmpNameCookie.Value = employeeRepository.Get(user.Id).Name; Response.Cookies.Add(loginEmpNameCookie); return(RedirectToAction("Index", "Employee")); case UserType.Labour: // logged in user is labour return(RedirectToAction("Index", "Labour")); default: // logged in user is admin return(RedirectToAction("Index", "Admin")); } } viewModel.Invalid = true; return(View("Login", viewModel)); }