public IHttpActionResult Attend([FromBody] int courseId)
        {
            var userId = User.Identity.GetUserId();

            if (_dbContext.Attendances.Any(a => a.AttendeeId == userId && a.CourseId == courseId))
            {
                return(BadRequest("The Attendance already exists!"));
            }
            var attendance = new Attendance
            {
                CourseId   = courseId,
                AttendeeId = userId
            };

            _dbContext.Attendances.Add(attendance);
            _dbContext.SaveChanges();
            return(Ok());
        }
예제 #2
0

        
예제 #3
0
        public IHttpActionResult Follow(FollowingDto followingDto)
        {
            var userId = User.Identity.GetUserId();

            if (_dbConText.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == followingDto.FolloweeId))
            {
                return(BadRequest("Following already exists"));
            }
            var folowing = new Following
            {
                FollowerId = userId,
                FolloweeId = followingDto.FolloweeId
            };

            _dbConText.Followings.Add(folowing);
            _dbConText.SaveChanges();
            return(Ok());
        }