public IHttpActionResult Unbook(AttendenceDto dto) { var userId = User.Identity.GetUserId(); var recordInDb = _unitOfWork.Attendences.GetAttendenceByUserAndGig(userId, dto.GigId); if (recordInDb == null) { return(BadRequest("The atendence doesn't exist")); } _unitOfWork.Attendences.Remove(recordInDb); _unitOfWork.Complete(); return(Ok()); }
public void Unbook_CalledCorrectly_DeleteTheAttendance() { var gig = new Gig(_user.Id, "-", DateTime.Now.AddDays(1), _genre.Id); _context.Gigs.Add(gig); _context.SaveChanges(); var dto = new AttendenceDto { GigId = _context.Gigs.First().Id }; _controller.Attend(dto); _controller.Unbook(dto); _context.Attendences.Should().HaveCount(0); }
public void Attend_AttendanceExistInDb_ReturnBadRequest() { var gig = new Gig(_user.Id, "-", DateTime.Now.AddDays(1), _genre.Id); _context.Gigs.Add(gig); _context.SaveChanges(); var dto = new AttendenceDto { GigId = _context.Gigs.First().Id }; _controller.Attend(dto); var result = _controller.Attend(dto); result.Should().BeOfType <BadRequestErrorMessageResult>(); }
public IHttpActionResult Attend(AttendenceDto dto) { var userId = User.Identity.GetUserId(); if (_context.Attendences.Any(a => a.AttendeeId == userId && a.GigId == dto.GigId)) { return(BadRequest("The attendence is already exists")); } var attendence = new Attendence { GigId = dto.GigId, AttendeeId = userId }; _context.Attendences.Add(attendence); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Attend(AttendenceDto attendenceDto) { var userId = User.Identity.GetUserId(); if (_context.Attendances.Any(a => a.GigId == attendenceDto.GigId && a.AttendeeId == userId)) { return(BadRequest("Comparecimento já estava confirmado")); } var attendance = new Attendance() { AttendeeId = userId, GigId = attendenceDto.GigId }; _context.Attendances.Add(attendance); _context.SaveChanges(); return(Ok("")); }
public IHttpActionResult Attend(AttendenceDto attendanceDto) { var usreId = User.Identity.GetUserId(); if (_dbContext.Attendances.Any(a => a.AttendeeId == usreId && a.CourseId == attendanceDto.CourseId)) { return(BadRequest("The Attendence alrealy exists")); } var attendence = new Attendance() { CourseId = attendanceDto.CourseId, AttendeeId = User.Identity.GetUserId() }; _dbContext.Attendances.Add(attendence); _dbContext.SaveChanges(); return(Ok()); }
public IHttpActionResult Attend(AttendenceDto dto) { var userId = User.Identity.GetUserId(); var exist = _context.Attendences.Any(u => u.AttendeeId == userId && u.GigId == dto.GigId); if (exist) { return(BadRequest("The attendance is already exist.")); } var attendee = new Attendence() { GigId = dto.GigId, AttendeeId = userId }; _context.Attendences.Add(attendee); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Attendence(AttendenceDto dto) { var attendeeId = User.Identity.GetUserId(); var exits = _context.Attendences.Any(a => a.AttendeeId == attendeeId && a.GigId == dto.GigId); if (exits) { return(BadRequest("the attendence already exists")); } var attendecne = new Attendence { GigId = dto.GigId, AttendeeId = attendeeId }; _context.Attendences.Add(attendecne); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Attend(AttendenceDto dto) { var currentUser = User.Identity.GetUserId(); if (_applicationDbContext.Attendances .Any(a => a.AttendeeId == currentUser && a.GigId == dto.GigId)) { return(BadRequest()); } var attendence = new Attendance { GigId = dto.GigId, AttendeeId = currentUser }; _applicationDbContext.Attendances.Add(attendence); _applicationDbContext.SaveChanges(); return(Ok()); }
public IHttpActionResult Attend(AttendenceDto dto) { var userId = User.Identity.GetUserId(); var recordExistInDb = _unitOfWork.Attendences.GetAttendenceExistInDb(userId, dto.GigId); if (recordExistInDb) { return(BadRequest("The attendence already exist")); } var attendence = new Attendence { GigId = dto.GigId, AttendeeId = userId }; _unitOfWork.Attendences.Add(attendence); _unitOfWork.Complete(); return(Ok()); }