public async void UnassignPetIllness(int petId, int illnessId) { PetIllness petIllness = await _context.PetIllnesses.FindAsync(illnessId, petId); if (petIllness != null) { Remove(petIllness); } }
public async Task AssignPetIllness(int petId, int illnessId) { PetIllness petIllness = await _context.PetIllnesses.FindAsync(petId, illnessId); if (petIllness == null) { petIllness = new PetIllness { PetId = petId, IllnesstId = illnessId }; await AddAsync(petIllness); } }
public async Task <PetIllnessResponse> UnassignPetIllness(int petId, int illnessId) { try { PetIllness petIllness = await _petIllnessRepository.FindByPetIdAndIllnessId(petId, illnessId); _petIllnessRepository.UnassignPetIllness(petId, illnessId); await _unitOfWork.CompleteAsync(); return(new PetIllnessResponse(petIllness)); } catch (Exception ex) { return(new PetIllnessResponse($"An error ocurred while unassigning Pet to Illness: {ex.Message}")); } }
public void Remove(PetIllness petIllness) { _context.PetIllnesses.Remove(petIllness); }
public async Task AddAsync(PetIllness petIllness) { await _context.PetIllnesses.AddAsync(petIllness); }