Click here to Skip to main content
14,661,016 members
Rate this:
Please Sign up or sign in to vote.
See more:
public IQueryable<VisitorDM> GetVisitorsReport(string fromDate, string toDate, int cityId, int page)
     {
         List<VisitorDM> lstVistorDetails = new List<VisitorDM>();
         VisitorListBL visitorListBL = new VisitorListBL();
         DateTime dtmfrmDate = DateTime.MinValue;
         DateTime dtmtoDate = DateTime.MinValue;

         using (VMSDBContext context = DAL.Instance.NewDefaultDbContext())
         {
             if (!string.IsNullOrEmpty(fromDate) && !string.IsNullOrEmpty(toDate))
             {
                 dtmfrmDate = Convert.ToDateTime(Convert.ToDateTime(fromDate).ToString("dd/MM/yyyy"));
                 dtmtoDate = Convert.ToDateTime(Convert.ToDateTime(toDate).ToString("dd/MM/yyyy"));

                 IEnumerable<VisitorDM> VisitorReportList = visitorListBL.GetVisitorHistoryList(cityId, page)
                     .Where(
                      objVisitorReportList =>
                      (
                         (objVisitorReportList.Office_in_time.Value.Day == dtmfrmDate.Day
                          && objVisitorReportList.Office_in_time.Value.Month == dtmfrmDate.Month
                          && objVisitorReportList.Office_in_time.Value.Year == dtmfrmDate.Year)
                      &&
                      (!string.IsNullOrEmpty(objVisitorReportList.Office_out_time.Value.ToString()) ?
                         (objVisitorReportList.Office_out_time.Value.Day == toDate.Day
                          && objVisitorReportList.Office_out_time.Value.Month == toDate.Month
                          && objVisitorReportList.Office_out_time.Value.Year == toDate.Year) : true)
                      )
                      ));

                 lstVistorDetails = VisitorReportList.ToList();
             }
             else
             {
                 IEnumerable<VisitorDM> VisitorReportList = visitorListBL.GetVisitorHistoryList(cityId, page);
                 lstVistorDetails = VisitorReportList.ToList();
             }
         }
         return lstVistorDetails.ToList().AsQueryable();
     }
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

what problem you face in this code
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100