예제 #1
0
        public IActionResult Create([FromBody] V1.RefereeRequest referee)
        {
            _context.Referees.Add(referee.ToEntity());
            _context.SaveChanges();

            return(NoContent());
        }
예제 #2
0
        public IActionResult Update(int id, [FromBody] V1.RefereeRequest RefereeRequest)
        {
            Referee referee = _context.Referees.ToListAsync().Result.Where(i => i.ToDto().Id == id).FirstOrDefault();

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



            _context.SaveChanges();

            return(NoContent());
        }
예제 #3
0
        public void Create_New_Referee()
        {
            //Arrange
            RefereeController controller = new RefereeController(_context);

            V1.RefereeRequest referee = new V1.RefereeRequest()
            {
                Name          = "Pierluigi Collina",
                MinutesPlayed = 270,
            };

            //Act
            var resultCreate = controller.Create(referee);
            var result       = controller.Get();

            //Assert
            Assert.IsType <NoContentResult>(resultCreate);
            var typedResult = (IEnumerable <V1.RefereeResponse>)Assert.IsType <OkObjectResult>(result).Value;

            typedResult.Should().HaveCount(3);
            typedResult.Should().Contain(s => s.Name == "Pierluigi Collina")
            .And.Contain(s => s.Name == "Eduardo Iturralde")
            .And.Contain(s => s.Name == "Graham Poll");
        }