Exemplo n.º 1
0
        public ActivityWorker AttachWoker(Activity activity, Worker worker, double hours, string comment)
        {
            ActivityWorkerBusinessLogic activityWorkerBusinessLogic = new ActivityWorkerBusinessLogic();
            ActivityWorker activityWorker = null;


            if (activity.GetWorkers().Contains(worker))
            {
                activityWorker = activity.GetActivityWorkerByWorker(worker);
                if (activityWorker.Hours != hours)
                {
                    activityWorker.Hours = hours;
                    activityWorkerBusinessLogic.Update(activityWorker);
                }

                return(activityWorker);
            }


            activityWorker = new ActivityWorker()
            {
                Activity = activity,
                Worker   = worker,
                Hours    = hours,
                Comment  = comment
            };

            activityWorkerBusinessLogic.Insert(activityWorker);

            activity.ActivityWorkers.Add(activityWorker);

            return(activityWorker);
        }
Exemplo n.º 2
0
        public double GetAvaiablesHoursByWorkerOnDate(Worker worker, DateTime date)
        {
            ActivityWorkerBusinessLogic activityWorkerBusinessLogic = new ActivityWorkerBusinessLogic();

            IList <ActivityWorker> list = activityWorkerBusinessLogic.GetAll().Where(o => o.Worker == worker && o.Activity.Date == date).ToList();

            double workedHours = list.Sum(o => o.Hours);

            double avaiableHours = MaxWorkHoursByDay() - workedHours;

            return(avaiableHours);
        }
Exemplo n.º 3
0
        public override void Delete(Worker obj)
        {
            ActivityWorkerBusinessLogic activityWorkerBusinessLogic = new ActivityWorkerBusinessLogic();
            ActivityBusinessLogic       activityBusinessLogic       = new ActivityBusinessLogic();

            var listWorked = activityWorkerBusinessLogic.GetAll().Where(o => o.Worker == obj).ToList();

            foreach (var item in listWorked)
            {
                activityBusinessLogic.DetachWoker(item.Activity, item.Worker);
            }

            this.baseDataAccessLayer.Delete(obj);
        }
Exemplo n.º 4
0
        public IList <Worker> GetByMajorWorkedHours(out double hours)
        {
            IList <Worker> list = null;

            ActivityWorkerBusinessLogic activityWorkerBusinessLogic = new ActivityWorkerBusinessLogic();
            IList <ActivityWorker>      listActivityWorkers         = activityWorkerBusinessLogic.GetAll();

            double d = listActivityWorkers.Max(aw => aw.Hours);

            listActivityWorkers = listActivityWorkers.Where(aw => aw.Hours == d).ToList();

            list  = listActivityWorkers.Select(aw => aw.Worker).Distinct().ToList();
            hours = d;
            return(list);
        }
Exemplo n.º 5
0
        public void DetachWoker(Activity activity, Worker worker)
        {
            if (!activity.GetWorkers().Contains(worker))
            {
                return;
            }


            ActivityWorker activityWorker = activity.GetActivityWorkerByWorker(worker);

            activity.ActivityWorkers.Remove(activityWorker);

            ActivityWorkerBusinessLogic activityWorkerBusinessLogic = new ActivityWorkerBusinessLogic();

            activityWorkerBusinessLogic.Delete(activityWorker);
        }