Beispiel #1
0
        private void CreateTimesheetUI()
        {
            var days = (WeeksOfYearVm.EndDate - WeeksOfYearVm.StartDate).TotalDays + 1;

            for (int i = 0; i < days; i++)
            {
                var currDate = WeeksOfYearVm.StartDate.AddDays(i);

                TimesheetVm.Add(new TimesheetVm
                {
                    Day        = currDate.ToString("dddd"),
                    Date       = currDate,
                    WorkHours  = 0F,
                    LunchHours = 0F,
                    Comments   = "",
                    isDisabled = !(currDate >= CurrentUser.ContractStartTime)
                });
            }

            if (WeeksOfYearVm.WeekNumber == Convert.ToInt32(CurrentWeekNumber))
            {
                TimesheetState = ApplicationContants.TS_STATUS_PLACEHOLDER + ApplicationContants.TS_NEW;
            }

            //if previous week
            if (WeeksOfYearVm.WeekNumber < Convert.ToInt32(CurrentWeekNumber))
            {
                isLastDayOfWeek = !(TimesheetVm.Any(tm => !tm.isDisabled));
                isSaveDisabled  = isLastDayOfWeek;
                if (!isLastDayOfWeek)
                {
                    TimesheetState = ApplicationContants.TS_STATUS_PLACEHOLDER + ApplicationContants.TS_PENDING_FOR_SUBMISSION;
                }
            }
            //if future week
            else if (WeeksOfYearVm.WeekNumber > Convert.ToInt32(CurrentWeekNumber))
            {
                isLastDayOfWeek = true;
                isSaveDisabled  = isLastDayOfWeek;
            }
        }
Beispiel #2
0
        private async Task GetTimesheetForUI()
        {
            WeeksOfYearVm = this.serviceFactory.WeeksOfYearService.GetWeekByWeekNumber(WeeksOfYearVm.WeekNumber);
            var user = await userManager.FindByNameAsync(User.Identity.Name);

            TimesheetVm = this.serviceFactory.TimesheetEntryService.GetUnApprovedTimesheetForWeek(WeeksOfYearVm.StartDate, WeeksOfYearVm.EndDate, user.Id).ToList();
            if (TimesheetVm.Count > 0)
            {
                if (TimesheetVm.Any(ts => ts.isSubmitted))
                {
                    DisableEntries = true;
                }
            }
            else
            {
                if (WeeksOfYearVm.WeekNumber.ToString() == CurrentWeekNumber)
                {
                    CreateTimesheetUI();
                }
            }
        }
Beispiel #3
0
        private async Task GetTimesheetForUI()
        {
            WeeksOfYearVm = this.serviceFactory.WeeksOfYearService.GetWeekByWeekNumber(WeeksOfYearVm.WeekNumber);

            RunningWeekNumber             = WeeksOfYearVm.WeekNumber.ToString();
            TempData["RunningWeekNumber"] = RunningWeekNumber;

            isLastDayOfWeek = true;

            var user = await userManager.FindByNameAsync(User.Identity.Name);

            CurrentUser = user;
            TimesheetVm = this.serviceFactory.TimesheetEntryService.GetUnApprovedTimesheetForWeek(WeeksOfYearVm.StartDate, WeeksOfYearVm.EndDate, user.Id).ToList();
            if (TimesheetVm.Count > 0)
            {
                if (TimesheetVm.Any(ts => ts.isSubmitted))
                {
                    if (TimesheetVm.Any(ts => ts.isRejected))
                    {
                        //DisableEntries = false;
                        TimesheetState   = ApplicationContants.TS_STATUS_PLACEHOLDER + ApplicationContants.TS_REJECTED;
                        pageIsRejected   = true;
                        isLastDayOfWeek  = false;
                        RejectionMessage = TimesheetVm[0].CommentFromApprover;
                        foreach (var tm in TimesheetVm)
                        {
                            tm.isDisabled = false;
                        }
                    }
                    else
                    {
                        pageIsRejected  = false;
                        isLastDayOfWeek = true;
                        isSaveDisabled  = isLastDayOfWeek;
                        TimesheetState  = ApplicationContants.TS_STATUS_PLACEHOLDER + ApplicationContants.TS_PENDING_FOR_APPROVAL;

                        foreach (var tm in TimesheetVm)
                        {
                            tm.isDisabled = true;
                        }
                    }
                }
                else if (TimesheetVm.Any(ts => ts.isSaveDraft))
                {
                    //isLastDayOfWeek = (WeeksOfYearVm.EndDate >= DateTime.Now.Date);
                    isLastDayOfWeek = !(DateTime.Now.Date >= WeeksOfYearVm.EndDate);

                    foreach (var tm in TimesheetVm)
                    {
                        tm.isDisabled = false;
                    }
                }
            }
            else
            {
                var TimesheetVm = this.serviceFactory.TimesheetEntryService.GetTSForWeekForUser(WeeksOfYearVm.StartDate, WeeksOfYearVm.EndDate, user.Id).ToList();

                if (TimesheetVm.Any(ts => ts.isApproved))
                {
                    pageIsApproved  = true;
                    isLastDayOfWeek = true;
                    isSaveDisabled  = isLastDayOfWeek;
                    ApprovedMessage = ApplicationContants.GEN_TS_APPROVE_MESSAGE;
                    TimesheetState  = ApplicationContants.TS_STATUS_PLACEHOLDER + ApplicationContants.TS_APPROVED;
                    foreach (var tm in TimesheetVm)
                    {
                        tm.isDisabled = true;
                    }
                }
                //else if (WeeksOfYearVm.WeekNumber.ToString() == CurrentWeekNumber)
                else
                {
                    pageIsApproved  = false;
                    isLastDayOfWeek = !(DateTime.Now.Date >= WeeksOfYearVm.EndDate);

                    CreateTimesheetUI();
                }
            }
        }