public async Task <JsonResult> Post([FromBody] Pet pet) { if (!_context.Pets.Contains(pet)) { _context.Pets.Add(pet); await _context.SaveChangesAsync(); return(new JsonResult(pet)); } else { return(new JsonResult(new { error = "This pet is in the database", petId = pet.Id })); } }
public async Task <JsonResult> Post([FromBody] Hospital hospital) { if (!_context.Hospitals.Contains(hospital)) { _context.Hospitals.Add(hospital); await _context.SaveChangesAsync(); return(new JsonResult(hospital)); } else { return(new JsonResult(new { error = "This person is in the database", hospitalId = hospital.Id })); } }
public async Task <JsonResult> Post([FromBody] Person person) { if (!_context.People.Contains(person)) { _context.People.Add(person); await _context.SaveChangesAsync(); return(new JsonResult(person)); } else { return(new JsonResult(new { error = "This person is in the database", personId = person.Id })); } }
public async Task <JsonResult> Post([FromBody] PetLocation petLocation) { _context.PetLocations.Add(petLocation); await _context.SaveChangesAsync(); return(new JsonResult(new { result = "Ok", petId = petLocation.PetId })); }