Ejemplo n.º 1
0
        public IEnumerable <WorkerLabel> GetWorkers()
        {
            if (UserRank == WorkerView.Rank.Manager)
            {
                try
                {
                    workers.Open();
                }catch (RepositoryOpenFailedExceptiom e)
                {
                    log.Exception(e, "Failed on tring to get all the users.");
                    log.Fetal("Fetal Error, App shuting down.");
                    Shutdown(1);
                }
                List <WorkerLabel> list = new List <WorkerLabel>();
                foreach (var item in workers.GetAll())
                {
                    list.Add(ViewConverter.CreateWorkerLabel(item));
                }
                try
                {
                    workers.Close();
                }catch (RepositorySaveFailedExceptiom e)
                {
                    log.Exception(e, "Failed on tring to get all the users.");
                    log.Fetal("Fetal Error, App shuting down.");
                    Shutdown(1);
                }

                return(list);
            }
            else
            {
                throw new UserAccessException("You dont have access to Workes Reposetory.");
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <WorkerLabel> GetWorkers(params Predicate <WorkerView>[] predicates)
        {
            if (UserRank == WorkerView.Rank.Manager)
            {
                try
                {
                    workers.Open();
                }
                catch (RepositoryOpenFailedExceptiom e)
                {
                    log.Exception(e, "Failed on tring to get users.");
                    log.Fetal("Fetal Error, App shuting down.");
                    Shutdown(1);
                }
                List <WorkerLabel> list = new List <WorkerLabel>();
                foreach (var item in workers.GetAll())
                {
                    var  itemView = ViewConverter.CreateWorkerView(item);
                    bool found    = false;
                    foreach (var pred in predicates)
                    {
                        if (pred(itemView))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (found)
                    {
                        list.Add(ViewConverter.CreateWorkerLabel(itemView));
                    }
                }
                try
                {
                    workers.Close();
                }
                catch (RepositorySaveFailedExceptiom e)
                {
                    log.Exception(e, "Failed on tring to get all the users.");
                    log.Fetal("Fetal Error, App shuting down.");
                    Shutdown(1);
                }
                return(list);
            }
            else
            {
                throw new UserAccessException("You dont have access to Workes Reposetory.");
            }
        }