public IActionResult Index(string id) { var currentPeriod = _periodService.GetCurrentPeriod(); var report = _reportService.GetReport(currentPeriod.PeriodString, EmployerAccount.AccountId); if (!_reportService.CanBeEdited(report)) { return(new RedirectResult(Url.Action("Index", "Home"))); } var currentSection = report.GetQuestionSection(id); if (currentSection == null) { return(new NotFoundResult()); } var sectionViewModel = new SectionViewModel { CurrentPeriod = currentPeriod, Report = report, CurrentSection = currentSection }; if (sectionViewModel.CurrentSection.Questions != null) { sectionViewModel.Questions = currentSection.Questions.Select(s => new QuestionViewModel { Answer = s.Answer, Id = s.Id, Optional = s.Optional, Type = s.Type }).ToList(); } return(View("Index", sectionViewModel)); }
public HomeController(IReportService reportService, IEmployerAccountService employerAccountService, IWebConfiguration webConfiguration, IPeriodService periodService, IAuthorizationService authorizationService) : base(webConfiguration, employerAccountService) { _reportService = reportService; _periodService = periodService; _authorizationService = authorizationService; _currentPeriod = _periodService.GetCurrentPeriod(); submitLookup = new ReadOnlyDictionary <string, SubmitAction>( buildSubmitLookups()); }
public ReportController(IReportService reportService, IEmployerAccountService employerAccountService, IUserService userService, IWebConfiguration webConfiguration, IPeriodService periodService, IAuthorizationService authorizationService, IMediator mediatr) : base(webConfiguration, employerAccountService) { _reportService = reportService; _userService = userService; _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); _mediatr = mediatr ?? throw new ArgumentNullException(nameof(mediatr)); _currentPeriod = periodService.GetCurrentPeriod(); }
public void CreateReport(string employerId, UserModel user) { var currentPeriod = _periodService.GetCurrentPeriod(); var requestUser = new User { Name = user.DisplayName, Id = user.Id }; var request = new CreateReportRequest( requestUser, employerId, currentPeriod.PeriodString); var report = _mediator.Send(request).Result; if (report?.Id == null) { throw new Exception("Unable to create a new report"); } }
public PeriodDTO GetCurrentPeriod() { Period period = periodService.GetCurrentPeriod(); return(periodDTOMapper.MapToModel(period)); }