Exemplo n.º 1
0
        public HourViewModel(string date, int userID, int permission)
        {
            Permission = permission;
            Date       = DateTime.Parse(date);

            projectRepo = Project.GetAll();
            hourRepo    = Hour.GetAllByID();

            WorkData           = new List <Hour>();
            ProjectList        = new List <Project>();
            CalculatedTime     = TimeSpan.Zero;
            CalculatedWorktime = TimeSpan.Zero;
            CalculatedOvertime = TimeSpan.Zero;

            ProjectList = Project.GetAllByPersonID(Administracija.Models.ActiveSession.Current.ActiveUser.IDWorker);
            WorkList    = Hour.GetAllByDate(date, userID, string.Join(";", ProjectList.Select(c => c.IDProject.ToString()).ToArray <string>()));
            GenerateData();

            WorkData.ToList().ForEach(d => CalculatedTime     += d.WorkTimeAutomatic);
            WorkList.ToList().ForEach(d => CalculatedWorktime += d.Worktime);
            WorkList.ToList().ForEach(d => CalculatedOvertime += d.Overtime);
        }