public CourseSolution Create(CourseSolution courseSolution, Guid executorId) { //TODO: check if executor is course's member _context.Solutions.Add(courseSolution); _context.SaveChanges(); return(courseSolution); }
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); }
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(); }
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); }
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(); }
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)); }
public Review Create(Review review, Guid executorId) { _context.Reviews.Add(review); _context.SaveChanges(); return(review); }