public Participant DeleteParticipant(string participantId) { Evaluation evaluation = _participantService.GetAll() .Where(p => p.Id.Equals(participantId)) .Select(p => p.Evaluation) .First() ; Role[] canBePerformedBy = { Role.Facilitator, Role.OrganizationLead }; AssertCanPerformMutation(evaluation, canBePerformedBy); Participant subject = _participantService.GetParticipant(participantId); /* Safeguard against deleting the last Facilitator */ if (subject.Role.Equals(Role.Facilitator)) { int facilitators = evaluation.Participants .Where(p => p.Role.Equals(Role.Facilitator)) .Count() ; if (facilitators < 2) { string msg = "Cannot delete last Facilitator in Evaluation"; throw new InvalidOperationException(msg); } } return(_participantService.Remove(participantId)); }
public void Delete() { EvaluationService evaluationService = new EvaluationService(_context); Evaluation evaluation = evaluationService.GetAll().First(); ParticipantService participantService = new ParticipantService(_context); Participant participantCreate = participantService.Create("Delete_id", evaluation, Organization.Engineering, Role.Participant); participantService.Remove(participantCreate.Id); Assert.Throws <NotFoundInDBException>(() => participantService.GetParticipant(participantCreate.Id)); }
public void ParticipantDeletedFromEvaluation() { EvaluationService evaluationService = new EvaluationService(_context); Evaluation evaluation = evaluationService.GetAll().First(); ParticipantService participantService = new ParticipantService(_context); Participant participant = participantService.Create("ParticipantDeletedFromEvaluation_id", evaluation, Organization.Engineering, Role.Participant); int participantsBefore = evaluation.Participants.Count; participantService.Remove(participant.Id); int participantsAfter = evaluation.Participants.Count; Assert.Equal(participantsBefore - 1, participantsAfter); }
public Participant DeleteParticipant(string participantId) { return(_participantService.Remove(participantId)); }