public ActionResult GetList(JQueryDataTableParamModel param) { GenderService GenderService = new GenderService(); IEnumerable<GenderDto> allGenders = GenderService.GetAllExposeDto(); IEnumerable<GenderDto> filteredGenders; if (!string.IsNullOrEmpty(param.sSearch)) { //Used if particulare columns are filtered var nameFilter = Convert.ToString(Request["sSearch_1"]); //Optionally check whether the columns are searchable at all var isNameSearchable = Convert.ToBoolean(Request["bSearchable_1"]); filteredGenders = allGenders .Where(c => isNameSearchable && c.Name != null && c.Name.ToString().ToLower().Contains(param.sSearch.ToLower())); } else { filteredGenders = allGenders; } var isNameSortable = Convert.ToBoolean(Request["bSortable_1"]); var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func<GenderDto, string> orderingFunction = (c => sortColumnIndex == 1 && isNameSortable ? c.Name.ToString() : ""); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") filteredGenders = filteredGenders.OrderBy(orderingFunction); else filteredGenders = filteredGenders.OrderByDescending(orderingFunction); IEnumerable<GenderDto> displayedGenders; if (param.iDisplayLength != -1) displayedGenders = filteredGenders.Skip(param.iDisplayStart).Take(param.iDisplayLength); else displayedGenders = filteredGenders; var result = from c in displayedGenders select new[] { c.Id.ToString(), c.Name }; return Json(new { sEcho = param.sEcho, iTotalRecords = allGenders.Count(), iTotalDisplayRecords = filteredGenders.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }
public ActionResult GetList(JQueryDataTableParamModel param) { var ctx = new UsersContext(); var allUsers = ctx.UserProfiles; IEnumerable<UserProfile> filteredUsers; if (!string.IsNullOrEmpty(param.sSearch)) { //Used if particulare columns are filtered var usernameFilter = Convert.ToString(Request["sSearch_1"]); var rolenameFilter = Convert.ToString(Request["sSearch_2"]); var personnameFilter = Convert.ToString(Request["sSearch_3"]); //Optionally check whether the columns are searchable at all var isUsernameSearchable = Convert.ToBoolean(Request["bSearchable_1"]); var isRolenameSearchable = Convert.ToBoolean(Request["bSearchable_2"]); var isPersonnameSearchable = Convert.ToBoolean(Request["bSearchable_3"]); filteredUsers = allUsers .Where(c => isUsernameSearchable && c.UserName != null && c.UserName.ToLower().Contains(param.sSearch.ToLower())); } else { filteredUsers = allUsers; } var isUsernameSortable = Convert.ToBoolean(Request["bSortable_1"]); var isRolenameSortable = Convert.ToBoolean(Request["bSortable_2"]); var isPersonnameSortable = Convert.ToBoolean(Request["bSortable_3"]); var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func<UserProfile, string> orderingFunction = (c => sortColumnIndex == 1 && isUsernameSortable ? c.UserName : ""); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") filteredUsers = filteredUsers.OrderBy(orderingFunction); else filteredUsers = filteredUsers.OrderByDescending(orderingFunction); IEnumerable<UserProfile> displayedUsers; if (param.iDisplayLength != -1) displayedUsers = filteredUsers.Skip(param.iDisplayStart).Take(param.iDisplayLength); else displayedUsers = filteredUsers; var result = from c in displayedUsers select new string[] { c.UserId.ToString() ,c.UserName ,unitOfWork.PersonAccountRepository.Get(m=>m.UserId==c.UserId).FirstOrDefault() !=null ? unitOfWork.PersonAccountRepository.Get(m=>m.UserId==c.UserId).FirstOrDefault().Person !=null ? unitOfWork.PersonAccountRepository.Get(m=>m.UserId==c.UserId).FirstOrDefault().Person.Lastname + " " + unitOfWork.PersonAccountRepository.Get(m=>m.UserId==c.UserId).FirstOrDefault().Person.Firstname : string.Empty: string.Empty ,Roles.FindUsersInRole(RoleNames.view1Role,c.UserName).FirstOrDefault()!=null ? "1" : "0" ,Roles.FindUsersInRole(RoleNames.view2Role,c.UserName).FirstOrDefault()!=null ? "1" : "0" ,Roles.FindUsersInRole(RoleNames.view3Role,c.UserName).FirstOrDefault()!=null ? "1" : "0" ,Roles.FindUsersInRole(RoleNames.editRole,ctx.UserProfiles.FirstOrDefault(m=>m.UserId==c.UserId).UserName).FirstOrDefault()!=null ? "1" : "0" ,Roles.FindUsersInRole(RoleNames.deleteRole,c.UserName).FirstOrDefault()!=null ? "1" : "0" ,Roles.FindUsersInRole(RoleNames.adminRole,c.UserName).FirstOrDefault()!=null ? "1" : "0" }; return Json(new { sEcho = param.sEcho, iTotalRecords = allUsers.Count(), iTotalDisplayRecords = filteredUsers.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }
public ActionResult GetList(JQueryDataTableParamModel param) { PartnerStoreService PartnerStoreService = new PartnerStoreService(); var allPartnerStores = PartnerStoreService.GetAllExposeDto(); IEnumerable<PartnerStoreDto> filteredPartnerStores; if (!string.IsNullOrEmpty(param.sSearch)) { //Used if particulare columns are filtered var PartnerStoreIdFilter = Convert.ToString(Request["sSearch_1"]); //Optionally check whether the columns are searchable at all var isPartnerStoreIdSearchable = Convert.ToBoolean(Request["bSearchable_1"]); filteredPartnerStores = allPartnerStores .Where(c => isPartnerStoreIdSearchable && c.Name != null && c.Name.ToLower().Contains(param.sSearch.ToLower())); } else { filteredPartnerStores = allPartnerStores; } var isPartnerIdSortable = Convert.ToBoolean(Request["bSortable_1"]); var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func<PartnerStoreDto, string> orderingFunction = (c => sortColumnIndex == 1 && isPartnerIdSortable ? c.PartnerId.ToString() : ""); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") filteredPartnerStores = filteredPartnerStores.OrderBy(orderingFunction); else filteredPartnerStores = filteredPartnerStores.OrderByDescending(orderingFunction); IEnumerable<PartnerStoreDto> displayedPartnerStores; if (param.iDisplayLength != -1) displayedPartnerStores = filteredPartnerStores.Skip(param.iDisplayStart).Take(param.iDisplayLength); else displayedPartnerStores = filteredPartnerStores; var result = from c in displayedPartnerStores select new[] { c.Id.ToString(), c.PartnerId, c.PartnerName, c.StoreId, c.StoreName, c.AddressLine1, c.AddressLine2, c.City, c.State, c.Postcode, c.Country, c.Comment1, c.Comment2, c.Comment3, c.Email, c.PhoneNo, c.FaxNo, c.DCI_MyerStore, c.ReceiverID2, c.Udf1, c.Udf2, c.Udf3, c.Udf4, c.Udf5, c.Udf6, c.Udf7, c.Udf8, c.Udf9, c.Udf10 }; return Json(new { sEcho = param.sEcho, iTotalRecords = allPartnerStores.Count(), iTotalDisplayRecords = filteredPartnerStores.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }
public ActionResult GetList(JQueryDataTableParamModel param, string reportDate, int departmentId, int filter) { PersonService pservice = new PersonService(); IEnumerable<PersonDto> allPersons = new List<PersonDto>(); int? department = null; System.DateTime endedDate; if (!System.DateTime.TryParse(reportDate, out endedDate)) endedDate = System.DateTime.Now; if (departmentId != -1) department = departmentId; switch (filter) { case 1: if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view1Role)) allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, department, pservice.GetPersonIdByUserId(WebSecurity.CurrentUserId)); if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view2Role)) { Person p = pservice.GetPersonByUserId(WebSecurity.CurrentUserId); if (p != null) { if (p.Department != null) { if (p.Department.Id == departmentId) allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, departmentId, null); } } } if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view3Role)) allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, department, null); break; case 2: if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view1Role)) allPersons = pservice.GetListAllOfReleasedPersonDto(System.DateTime.Now, department, pservice.GetPersonIdByUserId(WebSecurity.CurrentUserId)); if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view2Role)) { Person p = pservice.GetPersonByUserId(WebSecurity.CurrentUserId); if (p != null) { if (p.Department != null) { if (p.Department.Id == departmentId) allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, departmentId, null); } } } if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view3Role)) allPersons = pservice.GetListAllOfReleasedPersonDto(System.DateTime.Now, department, null); break; } IEnumerable<PersonDto> filteredPersons; if (!string.IsNullOrEmpty(param.sSearch)) { //Used if particulare columns are filtered var lastnameFilter = Convert.ToString(Request["sSearch_0"]); var firstnameFilter = Convert.ToString(Request["sSearch_1"]); var phongbanFilter = Convert.ToString(Request["sSearch_6"]); //Optionally check whether the columns are searchable at all var isLastnameSearchable = Convert.ToBoolean(Request["bSearchable_0"]); var isFirstnameSearchable = Convert.ToBoolean(Request["bSearchable_1"]); var isPhongBanSearchable = Convert.ToBoolean(Request["bSearchable_6"]); filteredPersons = allPersons .Where(c => isLastnameSearchable && c.Lastname != null && c.Lastname.ToString().ToLower().Contains(param.sSearch.ToLower()) || isFirstnameSearchable && c.Firstname != null && c.Firstname.ToString().ToLower().Contains(param.sSearch.ToLower()) ); } else { filteredPersons = allPersons; } var isLastnameSortable = Convert.ToBoolean(Request["bSortable_0"]); var isFirstnameSortable = Convert.ToBoolean(Request["bSortable_1"]); var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func<PersonDto, string> orderingFunction = (c => sortColumnIndex == 2 && isLastnameSortable ? c.Lastname.ToString() : sortColumnIndex == 3 && isFirstnameSortable ? c.Firstname.ToString() : ""); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") filteredPersons = filteredPersons.OrderBy(orderingFunction); else filteredPersons = filteredPersons.OrderByDescending(orderingFunction); IEnumerable<PersonDto> displayedPersons; if (param.iDisplayLength != -1) displayedPersons = filteredPersons.Skip(param.iDisplayStart).Take(param.iDisplayLength); else displayedPersons = filteredPersons; var result = from c in displayedPersons select new string[] { c.Id.ToString(), c.Lastname, c.Firstname, c.GenderName, c.Birthday, c.ChucDanhName, c.DepartmentName, c.PhoneNumber, c.Email, c.RecruitedDate, c.NgayNghi, c.Note }; return Json(new { sEcho = param.sEcho, iTotalRecords = allPersons.Count(), iTotalDisplayRecords = filteredPersons.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }
public ActionResult GetList(JQueryDataTableParamModel param) { ClientService clientService = new ClientService(); var allClients = clientService.GetAllExposeDto(); IEnumerable<ClientDto> filteredClients; if (!string.IsNullOrEmpty(param.sSearch)) { //Used if particulare columns are filtered var clientIdFilter = Convert.ToString(Request["sSearch_1"]); //Optionally check whether the columns are searchable at all var isClientIdSearchable = Convert.ToBoolean(Request["bSearchable_1"]); filteredClients = allClients .Where(c => isClientIdSearchable && c.Name != null && c.Name.ToLower().Contains(param.sSearch.ToLower())); } else { filteredClients = allClients; } var isClientIdSortable = Convert.ToBoolean(Request["bSortable_1"]); var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func<ClientDto, string> orderingFunction = (c => sortColumnIndex == 1 && isClientIdSortable ? c.ClientId.ToString() : ""); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") filteredClients = filteredClients.OrderBy(orderingFunction); else filteredClients = filteredClients.OrderByDescending(orderingFunction); IEnumerable<ClientDto> displayedClients; if (param.iDisplayLength != -1) displayedClients = filteredClients.Skip(param.iDisplayStart).Take(param.iDisplayLength); else displayedClients = filteredClients; var result = from c in displayedClients select new[] { c.Id.ToString(), c.IsActive, c.ClientId, c.ClientName, c.ShortName, c.AddressLine1, c.AddressLine2, c.City, c.State, c.Postcode, c.EDINo, c.Mfrid, c.NextPack, c.EndPack, c.NextASN, c.SupplierNo, c.TaxNo, c.ABN, c.Phone, c.ClientContactEmail, c.AQRAMEmail, c.FreightforwarderEmail, c.Line.ToString(), c.EntryName, c.Import, c.ImportNote }; return Json(new { sEcho = param.sEcho, iTotalRecords = allClients.Count(), iTotalDisplayRecords = filteredClients.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }