private ProgressStatus MapProgressStatus(UpdateLearningDayOperationRequest.LearningDayTopic learningDayTopic) { return(learningDayTopic.ProgressStatus switch { UpdateLearningDayOperationRequest.ProgressStatus.InProgress => ProgressStatus.InProgress, UpdateLearningDayOperationRequest.ProgressStatus.Done => ProgressStatus.Done, _ => throw new ArgumentOutOfRangeException() });
private LearningDayTopic CreateDayTopic( Domain.Entity.LearningCalendar.Employee employee, UpdateLearningDayOperationRequest.LearningDayTopic requestTopic) { if (requestTopic.ProgressStatus == UpdateLearningDayOperationRequest.ProgressStatus.Done) { var targetGoal = employee.PersonalGoals .FirstOrDefault(goal => goal.TopicId == requestTopic.TopicId && !goal.IsComplete); targetGoal?.MarkAsComplete(); } return(new LearningDayTopic { ProgressStatus = MapProgressStatus(requestTopic), TopicId = requestTopic.TopicId }); }
private void UpdateDayTopic( Domain.Entity.LearningCalendar.Employee employee, UpdateLearningDayOperationRequest.LearningDayTopic requestTopic, LearningDayTopic dayTopic) { var newStatus = MapProgressStatus(requestTopic); bool goalsShouldBeCompleted = newStatus != dayTopic.ProgressStatus && newStatus == ProgressStatus.Done; if (goalsShouldBeCompleted) { var targetGoal = employee.PersonalGoals .FirstOrDefault(goal => goal.TopicId == requestTopic.TopicId && !goal.IsComplete); targetGoal?.MarkAsComplete(); } dayTopic.ProgressStatus = newStatus; dayTopic.TopicId = requestTopic.TopicId; }