Exemple #1
0
        // GET: Coaches/Edit/5
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CoachServices services = new CoachServices(_context);
            Coach         coach    = services.GetCoach((int)id);

            if (coach == null)
            {
                return(NotFound());
            }

            SecurityServices secServices = new SecurityServices(_context);
            bool             isValid     = secServices.IsClubIDValidToClubNumber(coach.ClubID, User.Identity.Name);

            if (isValid == true)
            {
                return(View(coach));
            }
            else
            {
                return(RedirectToAction("YouCanOnlyLookUpYourOwnData", "Verify"));
            }
        }
Exemple #2
0
        public async Task GetCoachTest()
        {
            int coachid = 1;
            var Coach   = new Coach()
            {
                CoachId = coachid, CoachName = "Coach One"
            };

            var fakeRepositoryMock = new Mock <ICoachRepository>();

            fakeRepositoryMock.Setup(x => x.GetCoach(coachid)).ReturnsAsync(Coach);

            var CoachService = new CoachServices(fakeRepositoryMock.Object);

            var resultCoach = await CoachService.GetCoach(coachid);

            Assert.Equal("Coach One", resultCoach.CoachName);
        }