Esempio n. 1
0
        public TaskOversiktViewModel(int userId, int week, int year)
        {
            Dictionary<String, Dictionary<int, double>> tmp = new Dictionary<string, Dictionary<int, double>>();

            _repo = new TimeforingRepository();
            User = _repo.GetUser(userId);

            Dates = Util.GenerateDates(week, year);
            GenerateTasks(week, year);

            foreach (var date in Dates)
            {
                if (!tmp.ContainsKey(date.ToString("ddMMyyyy")))
                    tmp.Add(date.ToString("ddMMyyyy"), new Dictionary<int, double>());
                var timeføringer = from t in User.HourRegs
                                   where t.Date == date
                                   select t;
                foreach (var timeføring in timeføringer)
                {
                    if (!tmp[date.ToString("ddMMyyyy")].ContainsKey(timeføring.Task.TaskID))
                        tmp[date.ToString("ddMMyyyy")][timeføring.Task.TaskID] = timeføring.TimeSpent;
                    else
                        tmp[date.ToString("ddMMyyyy")][timeføring.Task.TaskID] += timeføring.TimeSpent;
                }
            }
            Timer = tmp;
        }
Esempio n. 2
0
        public IndexViewModel()
        {
            TimeforingRepository repo = new TimeforingRepository();
            var ctx = System.Web.HttpContext.Current;
            var c = ctx.Request.Cookies["TimeRegUser"];

            if (c != null)
            {
                int userId;
                if (int.TryParse(c.Value, out userId))
                {
                    User last = repo.GetUser(int.Parse(c.Value));
                    Users = SelectListMaker.UsersWithSelected(last);
                }
                else
                {
                    Users = SelectListMaker.Users();
                }

            }
            else
            {
                Users = SelectListMaker.Users();
            }
            Weeks = Util.GenerateWeekDropdown(DateTime.Today);
        }
Esempio n. 3
0
        public TimeOversiktViewModel(int userId, int weekNum, int year)
        {
            Dictionary<String, Dictionary<String, double>> tmp = new Dictionary<string, Dictionary<String, double>>();
            _repo = new TimeforingRepository();

            User = _repo.GetUser(userId);
            Week = weekNum.ToString();
            Dates = Util.GenerateDates(weekNum, year);
            GenerateTasks(weekNum, year);

            foreach (var date in Dates)
            {
                if (!tmp.ContainsKey(date.ToString("ddMMyyyy")))
                    tmp.Add(date.ToString("ddMMyyyy"), new Dictionary<String, double>());
                var timeføringer = User.HourRegs.Where(t => t.Date == date);
                foreach (var timeføring in timeføringer)
                {
                    if (!tmp[date.ToString("ddMMyyyy")].ContainsKey(timeføring.Task.Code.GetProjectAndCodenumber()))
                        tmp[date.ToString("ddMMyyyy")][timeføring.Task.Code.GetProjectAndCodenumber()] = timeføring.TimeSpent;
                    else
                        tmp[date.ToString("ddMMyyyy")][timeføring.Task.Code.GetProjectAndCodenumber()] += timeføring.TimeSpent;
                }
            }
            Timer = tmp;
        }
Esempio n. 4
0
 private void InitClass(int user, int week, DateTime date, string mess,bool showDoneTasks)
 {
     _repo = new TimeforingRepository();
     User = _repo.GetUser(user);
     Week = week.ToString();
     ShowDoneTasks = showDoneTasks;
     GenerateDatesInWeek(week, date);
     SetupTasks(user);
     FindHoursSpent(date);
     Message = mess;
 }