public ActionResult Employee() { var result = EmployeeInfoRepo.loadEmployees(); var model = new List <EmployeeInfoModel>(); if (!result.HasError) { foreach (var v in result.Data) { var emp = new EmployeeInfoModel() { Address = v.Address, Email = v.Email, ID = v.ID, IsActive = v.IsActive, Name = v.Name, UserCode = v.UserCode, UserName = v.UserName, UserTypeID = v.UserTypeID }; model.Add(emp); } } if (TempData["trash"] != null) { ViewBag.Success = TempData["trash"]; } if (TempData["trashError"] != null) { ViewBag.Error = TempData["trashError"]; } return(View(model)); }
public JsonResult GetSearchingDataEmployeeTrash(string SearchValue) { List <EmployeeInfoModel> empomers = new List <EmployeeInfoModel>(); var finalList = new List <EmployeeInfoModel>(); try { var result = EmployeeInfoRepo.loadEmployees(); if (result.HasError) { //return JavaScript("window.location = '/ManageUser/Employee'"); } foreach (var v in result.Data) { if (!v.IsActive) { var emp = new EmployeeInfoModel() { Address = v.Address, Email = v.Email, ID = v.ID, IsActive = v.IsActive, Name = v.Name, UserCode = v.UserCode, UserName = v.UserName, UserTypeID = v.UserTypeID }; empomers.Add(emp); } } var listByUserCode = empomers.Where(u => u.UserCode.ToString().Contains(SearchValue.Trim())).ToList(); var listByUserName = empomers.Where(u => u.UserName.Contains(SearchValue.Trim())).ToList(); var listByName = empomers.Where(u => u.Name.Contains(SearchValue.Trim())).ToList(); var listByMail = empomers.Where(u => u.Email.Contains(SearchValue.Trim())).ToList(); if (string.IsNullOrEmpty(SearchValue) || string.IsNullOrWhiteSpace(SearchValue)) { finalList = empomers; } else if ((listByUserCode.Count > listByUserName.Count || listByUserCode.Count == listByUserName.Count) && (listByUserCode.Count > listByName.Count || listByUserCode.Count == listByName.Count) && (listByUserCode.Count > listByMail.Count || listByUserCode.Count == listByMail.Count)) { finalList = listByUserCode; } else if ((listByUserName.Count > listByUserCode.Count || listByUserName.Count == listByUserCode.Count) && (listByUserName.Count > listByName.Count || listByUserName.Count > listByName.Count) && (listByUserName.Count > listByMail.Count || listByUserName.Count == listByMail.Count)) { finalList = listByUserName; } else if ((listByName.Count > listByUserName.Count || listByName.Count == listByUserName.Count) && (listByName.Count > listByUserCode.Count || listByName.Count == listByUserCode.Count) && (listByName.Count > listByMail.Count || listByName.Count == listByMail.Count)) { finalList = listByName; } else if ((listByMail.Count > listByUserName.Count || listByMail.Count == listByUserName.Count) && (listByMail.Count > listByName.Count || listByMail.Count == listByName.Count) && (listByMail.Count > listByUserCode.Count || listByMail.Count == listByUserCode.Count)) { finalList = listByMail; } } catch (FormatException) { //return JavaScript("window.location = '/ManageUser/Employee'"); } return(Json(finalList, JsonRequestBehavior.AllowGet)); }