Beispiel #1
0
        public virtual IActionResult UpdatePet([FromBody] Models.Pet body)
        {
            //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(400);

            //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(404);

            //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(405);


            throw new NotImplementedException();
        }
Beispiel #2
0
        public ActionResult <Models.Pet> UpdatePet(Guid guid, Models.Pet updatedPet)
        {
            try
            {
                var pet = _pet.GetPetByGuid(guid);
                if (updatedPet.Guid != guid)
                {
                    return(BadRequest());
                }
                if (pet == null)
                {
                    return(NotFound());
                }

                return(_pet.UpdatePet(guid, updatedPet));
            }
            catch (Exception e)
            {
                // _logger.LogError("Error", e);
                // throw;
                return(StatusCode(500, $"Internal server error: {e}"));
            }
        }
Beispiel #3
0
        public IHttpActionResult Post(Models.Pet pet)
        {
            Database.Entities.Pet dbPet = new Database.Entities.Pet()
            {
                ID          = Guid.NewGuid(),
                Adopted     = pet.Adopted,
                Name        = pet.Name,
                ImageUrl    = pet.ImageUrl,
                Description = pet.Description,
                BirthDate   = pet.BirthDate,
                Breed       = pet.Breed,
                FurType     = pet.FurType,
                Location    = pet.Location,
                MainColour  = pet.MainColour,
                PureBreed   = pet.PureBreed,
                Size        = pet.Size,
                Species     = pet.Species,
                OwnerID     = new Guid(User.Identity.GetUserId())
            };

            petService.Create(dbPet);

            return(Ok());
        }
Beispiel #4
0
 public IActionResult Insert([FromBody] Models.Pet pet)
 {
     _unitOfWork.PetRepository.Insert(pet);
     _unitOfWork.Complete();
     return(new JsonResult(pet));
 }
Beispiel #5
0
 public ActionResult <Models.Pet> AddPet(Models.Pet pet)
 {
     return(_pet.SetPet(pet));
 }