public IHttpActionResult Attend(AttendancesDto dto)
        {
            var artistId = User.Identity.GetUserId();
            var exists   = _dbContext.Attendances.Any(a => a.AttendeeId == artistId && a.EventId == dto.EventId);

            if (exists)
            {
                return(BadRequest("The attendance is already exists."));
            }
            var attendance = new Attendance
            {
                EventId    = dto.EventId,
                AttendeeId = artistId
            };

            _dbContext.Attendances.Add(attendance);
            _dbContext.SaveChanges();
            return(Ok());
        }
Пример #2
0
        public IHttpActionResult Attend(AttendancesDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Attendances.Any(a => a.AttendeeId == userId && a.GigId == dto.GigId))
            {
                return(BadRequest("The attendance already exists."));
            }

            var attendance = new Attendance
            {
                GigId      = dto.GigId,
                AttendeeId = userId
            };

            _context.Attendances.Add(attendance);
            _context.SaveChanges();

            return(Ok());
        }
        public IHttpActionResult Attend(AttendancesDto attendancesDto)
        {
            var userId = User.Identity.GetUserId();

            if (_dbContext.Attendances.Any(a => a.AttendeeId == userId && a.CourseId == attendancesDto.CourseId))
            {
                return(BadRequest("The Attendance is already exists!"));
            }

            var attendence = new Attendance
            {
                CourseId   = attendancesDto.CourseId,
                AttendeeId = userId
            };

            _dbContext.Attendances.Add(attendence);
            _dbContext.SaveChanges();

            return(Ok());
        }
Пример #4
0
        public IHttpActionResult Attend(AttendancesDto dto)
        {
            var UserId     = User.Identity.GetUserId();
            var attendance = _unitOfWork.AttendanceRepository.GetAttendance(dto.GigId, UserId);

            if (attendance != null)
            {
                return(BadRequest("the attendance already exist"));
            }

            attendance = new Attendance
            {
                GigId      = dto.GigId,
                AttendeeId = UserId
            };

            _unitOfWork.AttendanceRepository.Add(attendance);

            _unitOfWork.Complete();

            return(Ok());
        }