public async void UnassignPetTreatment(int petId, int treatmentId, DateTime date) { PetTreatment petTreatment = await FindByPetIdAndTreatmentIdAndDate(petId, treatmentId, date); if (petTreatment != null) { Remove(petTreatment); } }
public async Task AssignPetTreatment(int petId, int treatmentId, DateTime date) { PetTreatment petTreatment = await FindByPetIdAndTreatmentIdAndDate(petId, treatmentId, date); if (petTreatment == null) { petTreatment = new PetTreatment { PetId = petId, TreatmentId = treatmentId, Date = date }; await AddAsync(petTreatment); } }
public async Task <PetTreatmentResponse> UnassignPetTreatmentAsync(int petId, int treatmentId, DateTime date) { try { PetTreatment petTreatment = await _petTreatmentRepository.FindByPetIdAndTreatmentIdAndDate(petId, treatmentId, date); _petTreatmentRepository.UnassignPetTreatment(petId, treatmentId, date); await _unitOfWork.CompleteAsync(); return(new PetTreatmentResponse(petTreatment)); } catch (Exception ex) { return(new PetTreatmentResponse($"An error ocurred while unassigning Pet to Treatment {ex.Message}")); } }
public void Remove(PetTreatment petTreatment) { _context.PetTreatments.Remove(petTreatment); }
public async Task AddAsync(PetTreatment petTreatment) { await _context.PetTreatments.AddAsync(petTreatment); }