public ActionResult DisplayBenefitsOfWorker(long id, string Sorting_Order, string Search_Data, string Filter_Value, int?Page_No, string OrderType) { /*ViewBag.OrderType = OrderType ?? "desc"; * ViewBag.CurrentSortOrder = Sorting_Order; * Sorting_Order = Sorting_Order ?? "FirstName";*/ if (Search_Data != null) { Page_No = 1; } else { Search_Data = Filter_Value; } ViewBag.FilterValue = Search_Data; var benefitsList = hrServices.GetAllWorkerBenefits(id); /*if (!String.IsNullOrEmpty(Search_Data)) * { * benefitsList = benefitsList.Where(stu => stu.FirstName.ToUpper().Contains(Search_Data.ToUpper()) || * stu.Surname.ToUpper().Contains(Search_Data.ToUpper()) || * stu.FirstName.ToUpper().Contains(Search_Data.ToUpper()));///reszta * }*/ /*switch (Sorting_Order) * { * case "FirstName": * if (ViewBag.OrderType == "desc") * { * workers = workers.OrderByDescending(stu => stu.FirstName); * ViewBag.OrderType = "asc"; * } * else * { * workers = workers.OrderBy(stu => stu.FirstName); * ViewBag.OrderType = "desc"; * } * break; * case "Surname": * if (ViewBag.OrderType == "desc") * { * workers = workers.OrderByDescending(stu => stu.Surname); * ViewBag.OrderType = "asc"; * } * else * { * workers = workers.OrderBy(stu => stu.Surname); * ViewBag.OrderType = "desc"; * } * break; * case "Date": * if (ViewBag.OrderType == "desc") * { * workers = workers.OrderByDescending(stu => stu.DateOfBirth); * ViewBag.OrderType = "asc"; * } * else * { * workers = workers.OrderBy(stu => stu.DateOfBirth); * ViewBag.OrderType = "desc"; * } * break; * case "Employment": * if (ViewBag.OrderType == "desc") * { * workers = workers.OrderByDescending(stu => stu.Employment.EmploymentType); * ViewBag.OrderType = "asc"; * } * else * { * workers = workers.OrderBy(stu => stu.Employment.EmploymentType); * ViewBag.OrderType = "desc"; * } * break; * case "Position": * if (ViewBag.OrderType == "desc") * { * workers = workers.OrderByDescending(stu => stu.Employment.PositionCode); * ViewBag.OrderType = "asc"; * } * else * { * workers = workers.OrderBy(stu => stu.Employment.PositionCode); * ViewBag.OrderType = "desc"; * } * break; * //cd * default: * workers = workers.OrderBy(stu => stu.FirstName); * break; * }*/ int Size_Of_Page = 12; int No_Of_Page = (Page_No ?? 1); BenefitsViewModel bVM = new BenefitsViewModel(); bVM.Benefits = benefitsList.OrderByDescending(p => p.StartDate).ThenByDescending(n => n.StartDate.Month).ToPagedList(No_Of_Page, Size_Of_Page); bVM.PageCount = (int)Math.Ceiling((double)benefitsList.Count() / Size_Of_Page); bVM.PageNumber = Page_No ?? 1; var x = hrServices.GetWorker(id); bVM.PersonId = id; bVM.FirstName = x.FirstName; bVM.Surname = x.Surname; bVM.Position = hrServices.GetPositionName(x.Employment.PositionCode); bVM.Organization = hrServices.GetOrganizationName(x.Employment.OrganiziationalUnitCode); ViewBag.PersonId = id; return(View(bVM)); }