Exemple #1
0
        public (Guid Guid, Response Response) CreateReportCardDesign(NewReportDesignRequest request)
        {
            var validationResult = newReportCardDesignValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                return(Guid.Empty, Response.CreateResponse(validationResult.Messages));
            }

            var club = clubQuery.GetClub(request.ClubId);

            if (club == null)
            {
                return(Guid.Empty, Response.CreateResponse(new EntityNotFoundException("The specified club does not exist")));
            }

            var designs = reportDesignerQuery.GetReportCardDesigns(request.ClubId, request.Name);

            if (designs.Count() > 0)
            {
                return(Guid.Empty, Response.CreateResponse(new IllegalOperationException("There is already a report design with this name")));
            }

            try {
                var design = new ReportCardDesign(request.ClubId)
                {
                    DesignName = request.Name
                };
                reportDesignerRepository.AddReportDesign(design);
                return(design.Guid.Value, Response.CreateSuccessResponse());
            } catch (Exception ex) {
                return(Guid.Empty, Response.CreateResponse(ex));
            }
        }
        public IActionResult GetReportDesigns()
        {
            var reportDesigns = reportDesignerQuery.GetReportCardDesigns(club.Guid);

            return(Ok(new { results = reportDesigns.Select(r => new { ReportDesignId = r.Guid, Name = r.DesignName }) }));
        }
Exemple #3
0
        public IActionResult ReportCardDesigns()
        {
            var reportDesigns = reportDesignerQuery.GetReportCardDesigns(club.Guid);

            return(View(reportDesigns));
        }