Ejemplo n.º 1
0
        public StudentAssignmentDTO MapStudentAssignment(Assignment assignment, User user)
        {
            var dto = new StudentAssignmentDTO();

            MapAssignmentInternal(dto, assignment);

            var assignedTask = assignment.AssignmentTasks.FirstOrDefault(t => t.StudentsAssigned.Any(sa => sa.StudentId == user.Id));

            if (!(assignedTask is null))
            {
                dto.AssignedTask = taskMapper.MapTask(assignedTask);
            }

            return(dto);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The mentor approves the homework request sent by the student.
        /// </summary>
        /// <param name="toBeUpdated"></param>
        /// <returns></returns>
        public async Task ConfirmAssignmentAsync(StudentAssignmentDTO toBeUpdated)
        {
            var toBeUpdatedAssignment = await _studentAssignmentRepository.GetByIdAsync(toBeUpdated.Id).ConfigureAwait(false);

            toBeUpdatedAssignment.ThrowIfNullForGuidObject();

            var student = await _studentRepository.GetByIdAsync(toBeUpdatedAssignment.StudentId).ConfigureAwait(false);

            if (toBeUpdatedAssignment.IsApproved == true)
            {
                throw new MilvaUserFriendlyException("AssignmentActive");
            }

            toBeUpdatedAssignment.IsApproved   = true;
            toBeUpdatedAssignment.FinishedDate = toBeUpdated.FinishedDate;

            student.CurrentAssigmentDeliveryDate = toBeUpdatedAssignment.FinishedDate;
        }