Esempio n. 1
0
        public void Work()
        {
            Console.WriteLine("Enter FirstName");
            var firstName = Console.ReadLine();

            var position = GetSelectedPosition();

            if (position == Position.Worker)
            {
                Worker currentEmployee = Workers.FirstOrDefault(e => e.Name == firstName);

                currentEmployee.Work(currentEmployee.Task);
            }

            if (position == Position.Taskmaster)
            {
                Taskmaster currentTaskmaster = Taskmasters.FirstOrDefault(e => e.Name == firstName);

                Taskmaster.Work(currentTaskmaster.Task);
            }

            if (position == Position.Manager)
            {
                Manager currentManager = Managers.FirstOrDefault(e => e.Name == firstName);

                Manager.Work(currentManager.Task);
            }
        }
Esempio n. 2
0
        public void VerifyAppointedBy(Guid wasAppointed, Guid appointer, ICloneableException <Exception> e)
        {
            var toRemove = Owners.FirstOrDefault(o => o.OwnerGuid.Equals(wasAppointed));

            if (toRemove == null)
            {
                toRemove = Managers.FirstOrDefault(m => m.OwnerGuid.Equals(wasAppointed));
            }
            if (toRemove == null)
            {
                StackTrace stackTrace = new StackTrace();
                var        msg        = $"User with Guid - {wasAppointed} is not an owner or manager of shop {Guid}" +
                                        $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
                throw e.Clone(msg);
            }
            var byCreator = Creator.OwnerGuid.Equals(toRemove.AppointerGuid);
            var byOwner   = Owners.Any(o => o.OwnerGuid.Equals(toRemove.AppointerGuid));

            if (!(byCreator || byOwner))
            {
                StackTrace stackTrace = new StackTrace();
                var        msg        = $"User with Guid - {wasAppointed} was not appointed by {appointer}" +
                                        $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
                throw e.Clone(msg);
            }
        }
Esempio n. 3
0
        public Manager GetManager(Func <Manager, bool> predicate)
        {
            var item = Managers.FirstOrDefault(predicate);

            if (item == null)
            {
                item = Managers.Local.FirstOrDefault(predicate);
            }
            return(item);
        }
Esempio n. 4
0
        private void SetManager()
        {
            Managers = Collections.ManagerViewModels;

            ManagerViewModel = Managers.FirstOrDefault();

            if (ManagerViewModel != null)
            {
                ManagerViewModel.PropertyChanged += ManagerViewModel_PropertyChanged;
            }
            else
            {
                ManagerViewModel = new ManagerViewModel();
            }
        }
Esempio n. 5
0
        public void RemoveEmployee()
        {
            var position = GetSelectedPosition();

            Console.WriteLine("Enter FirstName to delete");
            var firstName = Console.ReadLine();

            if (position == Position.Worker)
            {
                Worker currentWorker = Workers.FirstOrDefault(e => e.Name == firstName);

                if (currentWorker != null)
                {
                    Workers.Remove(currentWorker);
                }
            }

            if (position == Position.Taskmaster)
            {
                Taskmaster currentTaskmaster = Taskmasters.FirstOrDefault(e => e.Name == firstName);

                if (currentTaskmaster != null)
                {
                    Taskmasters.Remove(currentTaskmaster);
                }
            }

            if (position == Position.Manager)
            {
                Manager currentManager = Managers.FirstOrDefault(e => e.Name == firstName);

                if (currentManager != null)
                {
                    Managers.Remove(currentManager);
                }
            }
        }
Esempio n. 6
0
 public T GetManager <T>() where T : Manager <T>, new()
 {
     return((T)Managers.FirstOrDefault(self => self.Key == typeof(T)).Value);
 }
Esempio n. 7
0
 public object GetManager(Type type)
 {
     return(Managers.FirstOrDefault(self => self.Key == type).Value);
 }
Esempio n. 8
0
 public bool IsLoadingManager <T>() where T : Manager <T>, new()
 {
     return(Managers.FirstOrDefault(self => self.Key == typeof(T)).Value is bool == false);
 }
Esempio n. 9
0
 public bool RemoveShopManager(Guid userGuid, Guid managerToRemoveGuid)
 {
     return(Managers.Remove(Managers.FirstOrDefault(o => o.OwnerGuid.Equals(managerToRemoveGuid))));
 }