Beispiel #1
0
        public static void search(viewOptions o, ref IQueryable <WorkOrder> q)
        {
            bool     isDateTime = false;
            DateTime parsedTime;

            if (isDateTime = DateTime.TryParse(o.sSearch, out parsedTime))
            {
                if (isMonthSpecific.IsMatch(o.sSearch))  //Regex for month/year
                {
                    q = q.Where(p => DbFunctions.DiffMonths(p.dateTimeofWork, parsedTime) == 0 ? true : false);
                }
                if (isDaySpecific.IsMatch(o.sSearch))  //Regex for day/month/year
                {
                    q = q.Where(p => DbFunctions.DiffDays(p.dateTimeofWork, parsedTime) == 0 ? true : false);
                }
                if (isTimeSpecific.IsMatch(o.sSearch)) //Regex for day/month/year time
                {
                    q = q.Where(p => DbFunctions.DiffHours(p.dateTimeofWork, parsedTime) == 0 ? true : false);
                }
            }
            else
            {
                q = q
                    .Where(p => SqlFunctions.StringConvert((decimal)p.ID).Contains(o.sSearch) ||
                           SqlFunctions.StringConvert((decimal)p.paperOrderNum).Contains(o.sSearch) ||
                           p.contactName.Contains(o.sSearch) ||
                           p.workSiteAddress1.Contains(o.sSearch) ||
                           p.updatedby.Contains(o.sSearch));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Filter WA queryable on a partial date string
 /// </summary>
 /// <param name="search">string that is part of a date</param>
 /// <param name="parsedTime">datetime.parse of the same string</param>
 /// <param name="query">WorkAssignment queryable</param>
 public static void filterOnDatePart(string search, DateTime parsedTime, ref IQueryable <WorkAssignment> query)
 {
     if (isMonthSpecific.IsMatch(search))  //Regex for month/year
     {
         query = query.Where(p => DbFunctions.DiffMonths(p.workOrder.dateTimeofWork, parsedTime) == 0 ? true : false);
     }
     if (isDaySpecific.IsMatch(search))  //Regex for day/month/year
     {
         query = query.Where(p => DbFunctions.DiffDays(p.workOrder.dateTimeofWork, parsedTime) == 0 ? true : false);
     }
     if (isTimeSpecific.IsMatch(search)) //Regex for day/month/year time
     {
         query = query.Where(p => DbFunctions.DiffHours(p.workOrder.dateTimeofWork, parsedTime) == 0 ? true : false);
     }
     //throw new ArgumentException("Date string not valid for Month,Day, or Hour pattern");
 }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        public static IQueryable <WorkOrder> filterDateTimeOfWork(IQueryable <WorkOrder> query, string search)
        {
            //Using DateTime.TryParse as determiner of date/string
            DateTime parsedTime;

            if (DateTime.TryParse(search, out parsedTime))
            {
                if (isMonthSpecific.IsMatch(search))  //Regex for month/year
                {
                    return(query.Where(p => DbFunctions.DiffMonths(p.dateTimeofWork, parsedTime) == 0 ? true : false));
                }
                if (isDaySpecific.IsMatch(search))  //Regex for day/month/year
                {
                    return(query.Where(p => DbFunctions.DiffDays(p.dateTimeofWork, parsedTime) == 0 ? true : false));
                }
                if (isTimeSpecific.IsMatch(search)) //Regex for day/month/year time
                {
                    return(query.Where(p => DbFunctions.DiffHours(p.dateTimeofWork, parsedTime) == 0 ? true : false));
                }
            }
            return(query);
        }
        public ActionResult Index()
        {
            // Hirer accounts use email addresses as username, so the list filters out usernames that are
            // email addresses because this View only exists to modify internal Machete user accounts
            var users = _context.Users;

            if (users == null)
            {
                throw new ArgumentNullException();
            }
            var model = users
                        .Select(u => new UserSettingsViewModel {
                ProviderUserKey = u.Id,
                UserName        = u.UserName,
                Email           = u.Email,
                IsApproved      = u.IsApproved ? "Yes" : "No",
                IsLockedOut     = u.IsLockedOut ? "Yes" : "No",
                IsOnline        = DbFunctions.DiffHours(u.LastLoginDate, DateTime.Now) < 1 ? "Yes" : "No",
                CreationDate    = u.CreateDate,
                LastLoginDate   = u.LastLoginDate
            }).Where(u => !u.UserName.Contains("@"));

            return(View(model));
        }