public async Task UnassignExpertTopic(int tutortId, int topicId) { ExpertTopic expertTopic = await FindByTutorIdAndTopicId(tutortId, topicId); if (expertTopic != null) { Remove(expertTopic); } }
public async Task AssignExpertTopic(int tutorId, int topicId) { ExpertTopic expertTopic = await FindByTutorIdAndTopicId(tutorId, topicId); if (expertTopic == null) { expertTopic = new ExpertTopic { TutorId = tutorId, TopicId = topicId }; await AddAsync(expertTopic); } }
public async Task <ExpertTopicResponse> UnassignExpertTopicAsync(int tutorId, int topicId) { try { ExpertTopic expertTopic = await _expertTopicRepository.FindByTutorIdAndTopicId(tutorId, topicId); _expertTopicRepository.Remove(expertTopic); await _unitOfWork.CompleteAsync(); return(new ExpertTopicResponse(expertTopic)); } catch (Exception ex) { return(new ExpertTopicResponse($"An error ocurred while unassigning Topic from Tutor: {ex.Message}")); } }
public void Remove(ExpertTopic expertTopic) { _context.ExpertTopics.Remove(expertTopic); }
public async Task AddAsync(ExpertTopic expertTopic) { await _context.ExpertTopics.AddAsync(expertTopic); }