Beispiel #1
0
        public async Task <ActionResult> EditUserAttestation([FromBody] UserAttestationWideInputModel model)
        {
            if (model == null || model.StudentId < 1)
            {
                return(BadRequest());
            }
            IEnumerable <Group> groups = await groupStorage.GetTeacherGroupsById(model.TeacherId);

            StudentGroup tempStudentGroup = await groupStorage.StudentGroupGetByUserId(model.StudentId);

            Group group = await groupStorage.GroupGetById(tempStudentGroup.GroupId);

            if (groups.Contains(group))
            {
                await userAttestationStorage.UserAttestationEdit(UserAttestationWideMapper.ToDataModels(model));
            }
            return(Ok());
        }
Beispiel #2
0
        public static List <UserAttestation> ToDataModels(UserAttestationWideInputModel wideModel)
        {
            List <UserAttestation> listOfAttestations = new List <UserAttestation>();

            foreach (var item in wideModel.PassedThemes)
            {
                ThemePass       theme       = PassedThemesMapper.ToDataModel(item);
                UserAttestation attestation = new UserAttestation
                {
                    UserId             = wideModel.StudentId,
                    AttestationThemeId = theme.ThemeId,
                    TheoryPassed       = theme.TheoryPass,
                    PracticePassed     = theme.PracticePass,
                };
                listOfAttestations.Add(attestation);
            }
            return(listOfAttestations);
        }