コード例 #1
0
        public Animal CreateDog(Shelter.Shared.Dog dog)
        {
            var newDog = new Dog {
                name          = dog.name,
                DateOfBirth   = dog.DateOfBirth,
                IsChecked     = dog.IsChecked,
                KidFriendly   = dog.KidFriendly,
                DateOfArrival = dog.DateOfArrival,
                ShelterId     = dog.ShelterId,
                Barker        = dog.Barker,
                Race          = dog.Race
            };

            _context.Add(newDog);
            _context.SaveChanges();

            return(newDog);
        }
コード例 #2
0
        //[Authorize]
        //Create a dog
        public IActionResult DoCreateDog(Shelter.Shared.Dog dog)
        {
            Animal createdAnimal = _dataAccess.CreateDog(dog);

            return(createdAnimal == default(Shared.Animal) ? (IActionResult)NotFound("No animal found with these parameters") : Ok(createdAnimal));
        }