Ejemplo n.º 1
0
        public ActionResult updateUser(long id, [FromBody] UserItem user)
        {
            //TODO Check if user is allowed to update this item

            if (userDB.getUserItem(id) == null)
            {
                return(NotFound("No UserItem found for ID: " + id));
            }
            user.UserID = id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            user = userDB.editUserItem(id, user);
            return(Ok(user));
        }
Ejemplo n.º 2
0
        public IActionResult addUserGroupBinding([FromQuery] int UserID, [FromQuery] int GroupID)
        {
            IActionResult ret = null;

            //check User
            if (userDB.getUserItem(UserID) == null)
            {
                ret = BadRequest($"No UserItem with id {UserID} found");
            }
            //check Group
            if (groupsDB.getGroup(GroupID) == null)
            {
                ret = BadRequest($"No GroupItem with id {GroupID} found");
            }
            //create binding
            if (ret == null)
            {
                ret = Ok(userGroupBindingDB.addUserGroupBinding(UserID, GroupID));
            }
            return(ret);
        }
Ejemplo n.º 3
0
        public LectureItem[] getLectures(long userID)
        {
            LectureItem[] lectures = new LectureItem[0];
            UserItem      userItem = userDB.getUserItem(userID);

            if (userItem != null)
            {
                if (userItem.UserType.Name == "Student")
                {
                    string       studyGroup      = userItem.StudyGroup.ShortName;
                    SemesterItem currentSemester = semesterDB.getCurrentSemesterByStudyGroup(studyGroup);

                    if (currentSemester == null)
                    {
                        //Create pseudo-semester
                        currentSemester = new SemesterItem
                        {
                            Start      = getFirstOfMonth(),
                            End        = getFirstOfMonth().AddMonths(3),
                            StudyGroup = studyGroup
                        };
                    }
                    lectures = timetableDB.getSemesterLectures(studyGroup, currentSemester);
                }
                else if (userItem.UserType.Name == "Dozent")
                {
                    //ToDo: get dozID
                    string   dozID     = "Prof. Penzel";
                    DateTime startDate = getFirstOfMonth();
                    DateTime endDate   = startDate.AddMonths(3);
                    lectures = timetableDB.getLecturesByLecturer(dozID, startDate, endDate);
                }
            }

            return(lectures);
        }