Ejemplo n.º 1
0
        public IQueryable <Booking> Filter(IQueryable <Booking> query)
        {
            if (EmployeeId.NotNullOrLessThanOne())
            {
                query = query.Where(b => b.EmployeeId == EmployeeId);
            }

            if (VehicleId.NotNullOrLessThanOne())
            {
                query = query.Where(b => b.VehicleId == VehicleId);
            }

            if (Statuses != null)
            {
                query = query.Where(b => Statuses.Any(s => s == b.Status));
            }

            if (FromDate != null)
            {
                query = query.Where(b => b.StartDate > FromDate);
            }

            if (ToDate != null)
            {
                query = query.Where(b => b.EndDate < ToDate);
            }

            if (EmployeeUserName.NotNullOrEmpty())
            {
                query = query.Where(b => b.Employee.Identity.UserName == EmployeeUserName);
            }

            return(query);
        }
Ejemplo n.º 2
0
            public bool Hits(Combatant source, Combatant target, AbilityModifiers modifiers)
            {
                // auto hit conditions

                if (_odds >= 100)
                {
                    return(true);
                }
                if (Statuses.Count() == 1 && Statuses.Contains(Status.Frog) && target.Frog)
                {
                    return(true);
                }
                if (Statuses.Count() == 1 && Statuses.Contains(Status.Small) && target.Small)
                {
                    return(true);
                }
                if (target is Ally && Statuses.Any(s => new Status[] {
                    Status.Haste,
                    Status.Berserk,
                    Status.Shield
                }.Contains(s)))
                {
                    return(true);
                }

                int odds = _odds;

                odds  = MPTurbo(odds, modifiers);
                odds  = Split(odds, modifiers);
                odds -= 1;

                return(source.CurrentBattle.Random.Next(99) < odds);
            }
Ejemplo n.º 3
0
 /// <summary>
 /// Removes a status from the player, if he is already affected by that status
 /// </summary>
 /// <param name="status">The status to remove to the player</param>
 /// <exception cref="PlayerStatusNotPresentException">If the player was not actually affected by that status</exception>
 public void RemoveStatus(PlayerStatus status)
 {
     if (Statuses.Any(x => x.Status == status))
     {
         Statuses.RemoveAll(x => x.Status == status);
     }
     else
     {
         throw new PlayerStatusNotPresentException();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Applies a status to the player, if he was not already affected by that status
 /// </summary>
 /// <param name="status">The status to add to the player</param>
 /// <exception cref="PlayerStatusAlreadyAppliedException">If the player already had that status</exception>
 public void ApplyStatus(PlayerStatus status)
 {
     if (!Statuses.Any(x => x.Status == status))
     {
         Statuses.Add(new ActivePlayerStatus(this, status));
     }
     else
     {
         throw new PlayerStatusAlreadyAppliedException();
     }
 }
Ejemplo n.º 5
0
        public void AddStatus(TaskStatus status, bool isUserSet = false)
        {
            if (Statuses.Any(x => x.Status == status))
            {
                Debug.Assert(false);
                return;
            }

            LastStatus = status;
            Statuses.Add(new TaskStatusData {
                Status = status, IsUserSet = isUserSet
            });
        }
        private Expression <Func <ChangeRequestDocument, bool> > AddStatusFilter(
            Expression <Func <ChangeRequestDocument, bool> > filterEx)
        {
            if (Statuses == null || !Statuses.Any())
            {
                return(filterEx);
            }
            Expression <Func <ChangeRequestDocument, bool> > statusFilterEx = null;

            foreach (var status in Statuses)
            {
                statusFilterEx = statusFilterEx.OrElse(x => x.StatusText == status);
            }
            return(filterEx.AndAlso(statusFilterEx));
        }
Ejemplo n.º 7
0
        protected List <string> GetConditions()
        {
            List <string> conditions = new List <string>();

            if (Id.HasValue)
            {
                conditions.Add(" Id = @Id ");
            }

            if (CreatedFrom.HasValue || CreatedTo.HasValue)
            {
                conditions.Add(" (Created BETWEEN @CreatedFrom AND @CreatedTo) ");
            }

            if (Statuses != null && Statuses.Any())
            {
                conditions.Append(" Status = ANY ('{@Statuses}' ");
            }
            conditions.Append(" IncludeDeleted = @IncludeDeleted ");
            return(conditions);
        }
Ejemplo n.º 8
0
        public IQueryable <ITask> Where(IQueryable <ITask> tasks)
        {
            #region Фильтры

            tasks = tasks.Where(x => x.BoardId == BoardId);

            if (!IsAllIn(ExecutorIds, _AllUserIds))
            {
                tasks = from t in tasks
                        where ExecutorIds.Contains(t.ExecutorUserId)
                        select t;
            }

            if (!IsAllIn(CreatorIds, _AllUserIds))
            {
                tasks = from t in tasks
                        where CreatorIds.Contains(t.CreatorUserId)
                        select t;
            }

            if (!IsAllIn(ProjectIds, _AllProjectIds))
            {
                tasks = from t in tasks
                        where ProjectIds.Contains(t.ProjectId)
                        select t;
            }

            if (!IsAllIn(ColorIds, _AllColorIds))
            {
                tasks = from t in tasks
                        where ColorIds.Contains(t.ColorId)
                        select t;
            }

            if (!IsAllIn(Statuses, _AllStatuses))
            {
                if (Statuses.Any(x => x == TimezStatus.ArchiveStatusId || x <= 0))
                {
                    throw new ArgumentOutOfRangeException();
                }

                tasks = from t in tasks
                        where Statuses.Contains(t.TaskStatusId)
                        select t;
            }

            if (!string.IsNullOrWhiteSpace(Search))
            {
                tasks = from t in tasks
                        where t.Name.ToUpper().Contains(Search.Trim().ToUpper())
                        select t;
            }

            #endregion

            #region Ограничение по роли пользователя в доске

            UserRole role = _Settings.GetUserRole();
            if (!role.HasTheFlag(UserRole.Owner) && !role.HasTheFlag(UserRole.Observer))
            {
                // владелец и наблюдатель получают все задачи
                // исполнитель и заказчик только свои
                if (role.HasAnyFlag(UserRole.Executor | UserRole.Customer))
                {
                    // есть обе роли, значит нужно оба типа задач
                    tasks = from t in tasks
                            where t.ExecutorUserId == _Settings.UserId ||                          // назначенные на пользователя
                            t.CreatorUserId == _Settings.UserId                                // назначенные пользоватем
                            select t;
                }
                else if (role.HasTheFlag(UserRole.Executor))
                {
                    tasks = from t in tasks
                            where t.ExecutorUserId == _Settings.UserId                             // только назначенные на пользователя
                            select t;
                }
                else if (role.HasTheFlag(UserRole.Customer))
                {
                    tasks = from t in tasks
                            where t.CreatorUserId == _Settings.UserId                             // только назначенные пользоватем
                            select t;
                }
                else
                {
                    throw new AccessDeniedException();
                }
            }

            #endregion

            return(tasks);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Determines whether an application has a status
 /// </summary>
 /// <param name="status">status of the application</param>
 /// <returns>boolean perdicting whether the application has a status</returns>
 public bool HasStatus(EApplicationStatus status)
 {
     return(Statuses.Any(x => x.Status == status));
 }