public async Task <IActionResult> CreateClubAnnualReport([FromBody] ClubAnnualReportViewModel annualReport)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var clubAnnualReport = _mapper.Map <ClubAnnualReportViewModel, ClubAnnualReportDTO>(annualReport);
                    await _clubAnnualReportService.CreateAsync(await _userManager.GetUserAsync(User), clubAnnualReport);
                }
                catch (InvalidOperationException)
                {
                    return(StatusCode(StatusCodes.Status400BadRequest));
                }
                catch (NullReferenceException)
                {
                    return(StatusCode(StatusCodes.Status404NotFound));
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }

            return(StatusCode(StatusCodes.Status201Created));
        }
        public async Task CreateClubAnnualReport_Invalid_InvalidModelState_Test()
        {
            // Arrange
            AnnualReportController _annualReportController = CreateAnnualReportController;
            var _clubAnnualReportViewModel = new ClubAnnualReportViewModel();

            _annualReportController.ModelState.AddModelError("NameError", "Required");

            // Act
            var result = await _annualReportController.CreateClubAnnualReport(_clubAnnualReportViewModel);

            // Assert
            Assert.NotNull(result);
            Assert.IsInstanceOf <BadRequestObjectResult>(result);
        }
        public async Task CreateClubAnnualReport_Invalid_NullReferenceFoundException_Test()
        {
            // Arrange
            _clubAnnualReportService.Setup(a => a.CreateAsync(It.IsAny <User>(), It.IsAny <ClubAnnualReportDTO>()))
            .Throws(new NullReferenceException());

            AnnualReportController _annualReportController = CreateAnnualReportController;

            // Act
            var _clubAnnualReportViewModel = new ClubAnnualReportViewModel();
            var result = await _annualReportController.CreateClubAnnualReport(_clubAnnualReportViewModel);

            var expected = StatusCodes.Status404NotFound;
            var actual   = (result as StatusCodeResult).StatusCode;

            // Assert
            Assert.AreEqual(expected, actual);
            Assert.NotNull(result);
            Assert.IsInstanceOf <StatusCodeResult>(result);
        }
        public async Task CreateClubAnnualReport_Valid_Test()
        {
            // Arrange
            _clubAnnualReportService.Setup(a => a.CreateAsync(It.IsAny <User>(), It.IsAny <ClubAnnualReportDTO>()));
            _userManager.Setup(a => a.GetUserAsync(It.IsAny <ClaimsPrincipal>())).ReturnsAsync(new User());

            AnnualReportController _annualReportController = CreateAnnualReportController;
            var _clubAnnualReportViewModel = new ClubAnnualReportViewModel();

            // Act
            var result = await _annualReportController.CreateClubAnnualReport(_clubAnnualReportViewModel);

            var expected = StatusCodes.Status201Created;
            var actual   = (result as StatusCodeResult).StatusCode;

            // Assert
            Assert.AreEqual(expected, actual);
            Assert.NotNull(result);
            Assert.IsInstanceOf <StatusCodeResult>(result);
        }