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);
            }
        protected BusinessException(BusinessExceptionCode exceptionCode, string message)
        {
            ExceptionCode = exceptionCode;
            BusinessExceptionMessages.TryGetValue(exceptionCode, out errorMessage);

            if (!string.IsNullOrWhiteSpace(message))
            {
                fullMessage = message;
            }
        }
Beispiel #3
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);
                }
            }
 protected BusinessException(BusinessExceptionCode exceptionCode)
 {
     ExceptionCode = exceptionCode;
     BusinessExceptionMessages.TryGetValue(exceptionCode, out errorMessage);
 }