public Task HandleAsync(AddEditWeeklyReportPhrCommand request)
            {
                var rule = _rules.Value.PMsCanOnlyEditTheirReportsTill;

                if (!rule.IsEnabled)
                {
                    return(Task.CompletedTask);
                }

                if (request.RequestContext.AccessRights.Contains(AuthorizationHelper.ScopeUpdatePast) &&
                    request.RequestContext.AccessRights.Contains(AuthorizationHelper.ScopeCreatePast))
                {
                    return(Task.CompletedTask);
                }

                var isoDay             = TimeHelper.GetIsoDayOfWeek(rule.Day);
                var maxAllowedDateTime = TimeHelper.GetDateTimeOfXHourYDayNextZWeekFollowingYear(rule.Hour, isoDay, 1,
                                                                                                 request.Report.SelectedYear, request.Report.SelectedWeek);

                if (maxAllowedDateTime < DateTime.Now)
                {
                    BusinessExceptionCode.Throw(BusinessError.B001, request);
                }

                return(Task.CompletedTask);
            }
Esempio n. 2
0
            public async Task HandleAsync(AddProjectCommand request)
            {
                var projects = (await _mediator.SendAsync(new GetProjectsCachingQuery())).Projects;

                var existed = projects.FirstOrDefault(p => p.Code == request.Code);

                if (existed != null)
                {
                    BusinessExceptionCode.Throw(BusinessError.B002, request);
                }
            }