コード例 #1
0
        private IActionResult TryDelete(string name)
        {
            sports.DeleteSport(name);
            OkModelOut okMessage = new OkModelOut()
            {
                OkMessage = "The sport has been deleted successfully"
            };

            return(Ok(okMessage));
        }
コード例 #2
0
        private IActionResult TryToDelete(int id)
        {
            encounterService.DeleteEncounter(id);
            OkModelOut okMessage = new OkModelOut()
            {
                OkMessage = "The match was deleted successfully"
            };

            return(Ok(okMessage));
        }
コード例 #3
0
        private IActionResult TryUnFollow(int teamId)
        {
            IActionResult result;
            string        username = HttpContext.User.Claims.First(c => c.Type.Equals(AuthenticationConstants.USERNAME_CLAIM)).Value;

            userService.UnFollowTeam(username, teamId);
            OkModelOut okMessage = new OkModelOut()
            {
                OkMessage = "Team unfollowed succesfully"
            };

            result = Ok(okMessage);
            return(result);
        }
コード例 #4
0
        public void FollowTeamTest()
        {
            //Act.
            IActionResult  result    = controller.FollowTeam(3);
            OkObjectResult okResult  = result as OkObjectResult;
            OkModelOut     okMessage = okResult.Value as OkModelOut;

            //Assert.
            service.Verify(us => us.FollowTeam("username", 3));
            Assert.IsNotNull(result);
            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
            Assert.IsNotNull(okMessage);
        }
コード例 #5
0
        public void DeleteByIdTest()
        {
            //Act.
            IActionResult  result    = controller.Delete(2);
            OkObjectResult okResult  = result as OkObjectResult;
            OkModelOut     okMessage = okResult.Value as OkModelOut;

            //Assert.
            teamsService.Verify(r => r.DeleteTeam(2), Times.Once);
            Assert.IsNotNull(okResult);
            Assert.AreEqual(okResult.StatusCode, 200);
            Assert.IsNotNull(okMessage);
            Assert.IsNotNull("The Team was deleted successfully", okMessage.OkMessage);
        }
コード例 #6
0
        public void UnFollowTeamTest()
        {
            //Arrange.
            TeamModelIn input = GetTeamModelIn();

            //Act.
            IActionResult  result   = controller.UnFollowTeam(3);
            OkObjectResult okResult = result as OkObjectResult;
            OkModelOut     okModel  = okResult.Value as OkModelOut;

            //Assert.
            service.Verify(us => us.UnFollowTeam(It.IsAny <string>(), It.IsAny <int>()), Times.Once);
            Assert.IsNotNull(result);
            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
            Assert.IsNotNull(okModel);
        }
コード例 #7
0
        public IActionResult Delete(int id)
        {
            IActionResult result;

            try
            {
                SetSession();
                teamService.DeleteTeam(id);
                OkModelOut message = new OkModelOut {
                    OkMessage = "The team was deleted succesfully"
                };
                result = Ok(message);
            }
            catch (ServiceException e)
            {
                result = errors.GenerateError(e);
            }

            return(result);
        }
コード例 #8
0
        public IActionResult Delete(string username)
        {
            IActionResult result;

            try
            {
                SetSession();
                userService.DeleteUser(username);
                OkModelOut okMessage = new OkModelOut()
                {
                    OkMessage = "The user has been deleted successfully"
                };
                result = Ok(okMessage);
            }
            catch (ServiceException e)
            {
                result = errors.GenerateError(e);
            }

            return(result);
        }