コード例 #1
0
 public CourseSolution Create(CourseSolution courseSolution, Guid executorId)
 {
     //TODO: check if executor is course's member
     _context.Solutions.Add(courseSolution);
     _context.SaveChanges();
     return(courseSolution);
 }
コード例 #2
0
        public CourseTask Create(CourseTask courseTask, Guid executorId)
        {
            if (courseTask.AuthorId != executorId)
            {
                throw new ArgumentException("Other id marked as author");
            }

            _context.Add(courseTask);
            _context.SaveChanges();
            return(courseTask);
        }
コード例 #3
0
        public void SendInvite(Guid courseId, Guid targetId, Guid executorId)
        {
            var participation = new Participation
            {
                CourseId   = courseId,
                MemberId   = targetId,
                Permission = MemberPermission.Invited
            };

            _context.Participations.Add(participation);
            _context.SaveChanges();
        }
コード例 #4
0
        public Course Create(Course course, Guid executorId)
        {
            _context.Courses.Add(course);
            var partition = new Participation
            {
                CourseId   = course.Id,
                MemberId   = executorId,
                Permission = MemberPermission.Creator
            };

            _context.Participations.Add(partition);
            _context.SaveChanges();

            return(course);
        }
コード例 #5
0
        public void Update(PeerReviewUser peerReviewUser, Guid executorId)
        {
            //TODO: check if executorId is admin
            if (peerReviewUser.Id != executorId)
            {
                throw new PermissionDeniedException(executorId, "On PeerReviewUserService.Update");
            }

            //TODO: validate fields
            _context.Users.Update(peerReviewUser);
            _context.SaveChanges();
        }
コード例 #6
0
        public UserToken RegisterMember(RegistrationData data)
        {
            if (IsUsernameAvailable(data.Login) == false)
            {
                throw new DuplicateNameException(data.Login);
            }

            PeerReviewUser peerReviewUser = data.ToUser();

            _context.Users.Add(peerReviewUser);

            var authData = new AuthData {
                Login = data.Login, Password = data.Password
            };

            _context.AuthorizeDatas.Add(authData);
            _context.SaveChanges();

            return(LogIn(authData));
        }
コード例 #7
0
 public Review Create(Review review, Guid executorId)
 {
     _context.Reviews.Add(review);
     _context.SaveChanges();
     return(review);
 }