Esempio n. 1
0
        public async Task <IActionResult> Get(string id)
        {
            ObjectId parm     = ObjectId.Parse(id);
            var      practice = await _practiceRepository.GetPracticeById(parm);

            if (practice == null)
            {
                return(new NotFoundResult());
            }

            return(new ObjectResult(practice));
        }
        public IHttpActionResult GetById(int id)
        {
            _loggerService.CreateLog(_user, "API", "PracticeController", "Practice", "Get By Id", id.ToString(), null);

            Practice practice = _practiceRepository.GetPracticeById(id);

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

            return(Ok(practice));
        }
Esempio n. 3
0
        public void GetPracticeById()
        {
            //Arrange
            IPracticeRepository sut       = GetInMemoryPracticeRepository();
            Practice            practice1 = new Practice()
            {
                Id                = 1,
                Date              = DateTime.Parse("2020-12-11"),
                Rounds            = 1,
                Score             = 5,
                SkillId           = 2,
                Notes             = "Jo missed second contact on dogwalk.",
                DogId             = 3,
                ApplicationUserId = "d4eb7d23-d641-4c2d-8cd3-a036e08a3c65"
            };

            Practice practice2 = new Practice()
            {
                Id                = 2,
                Date              = DateTime.Parse("2020-12-12"),
                Rounds            = 1,
                Score             = 9,
                SkillId           = 1,
                Notes             = "Jo did very well.",
                DogId             = 3,
                ApplicationUserId = "d4eb7d23-d641-4c2d-8cd3-a036e08a3c65"
            };

            //Act
            Practice savedPractice1 = sut.CreatePractice(practice1);
            Practice savedPractice2 = sut.CreatePractice(practice2);

            //Assert
            var foundPracticeById = sut.GetPracticeById(1);

            Assert.Equal(5, foundPracticeById.Score);
        }