Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PetId,VetName,StreetAddress,City,State,ZipCode,WorkPhone,Allergy,Altered,Rabies,Bordetella")] VetRecord vetRecord)
        {
            if (id != vetRecord.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vetRecord);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VetRecordExists(vetRecord.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var PetId = vetRecord.PetId;
                return(RedirectToAction("Details", "Pets", new { id = PetId }));
            }
            return(View(vetRecord));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,PetId,VetName,StreetAddress,City,State,ZipCode,WorkPhone,Allergy,Altered,Rabies,Bordetella")] VetRecord vetRecord)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vetRecord);
                await _context.SaveChangesAsync();

                var PetId = vetRecord.PetId;
                return(RedirectToAction("Details", "Pets", new { id = PetId }));
            }
            return(View(vetRecord));
        }
Esempio n. 3
0
        // GET: VetRecords/Create
        public IActionResult Create(int?PetId = null)
        {
            var petRecord = new VetRecord();

            if (PetId != null)
            {
                petRecord.Id = (int)PetId;

                var pet = _context.Pets
                          .FirstOrDefault(x => x.Id == PetId);
                petRecord.Pet = pet;

                return(View(petRecord));
            }

            return(View());
        }