public async Task <IActionResult> Create([Bind("ID,RegisterDate,SerialNum,AnimalCategory,Breed,AnimalName,BirthDate,OwnerName,OwnerStreet,OwnerCity,OwnerState,OwnerZip,OwnerPhoneNum,PhotoUrl")] Pet pet)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pet);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(pet));
        }
예제 #2
0
        public Animal Add(Animal animal)
        {
            _context.Animal.Add(animal);
            try
            {
                _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (AnimalExists(animal.Id))
                {
                    return(animal);
                }
                else
                {
                    throw;
                }
            }

            return(animal);
        }