Пример #1
0
        public ActionResult DeletePet(Guid petId)
        {
            // Log Api call.  Could be moved to database for future anayltics.
            _log.WriteInformation("Controller:PetsController,API:AddDeletePetPet,DateTime:" + DateTime.Now.ToString());

            try
            {
                // Ensure pet exists.
                if (!_familyDemoAPIv2Repository.PetExists(petId).Result)
                {
                    return(NotFound());
                }

                var petToDelete = _familyDemoAPIv2Repository.GetPet(petId).Result; // Obtain record via DbContext query and store in entity.
                _familyDemoAPIv2Repository.DeletePet(petToDelete);                 // Call to repository delete method.
            }
            catch (Exception ex)
            {
                _log.WriteError(ex.Message, ex.InnerException);
                return(NoContent());
            }

            return(Ok());
        }