public IHttpActionResult DeleteAttendance(GigDto gigDto) { var userId = User.Identity.GetUserId(); var existingAttendance = _db.Attendances.SingleOrDefault(a => a.AttendeeId == userId && a.GigId == gigDto.Id); if (existingAttendance == null) { return(NotFound()); } _db.Attendances.Remove(existingAttendance); _db.SaveChanges(); return(Ok(gigDto.Id)); }
public IHttpActionResult AddGigToCalendar(GigDto gigDto) { var userId = User.Identity.GetUserId(); var exists = _context.Attendances .Any(a => a.GigId == gigDto.GigId && a.AttendeeId == userId); if (exists) { return(BadRequest("The Attendance already exists.")); } var attendance = new Attendance { GigId = gigDto.GigId, AttendeeId = User.Identity.GetUserId() }; _context.Attendances.Add(attendance); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult AddAttendance(GigDto gigDto) { var userId = User.Identity.GetUserId(); if (_db.Attendances.Any(a => a.AttendeeId == userId && a.GigId == gigDto.Id)) { BadRequest("attendance exists!"); } var attendance = new Attendance() { GigId = gigDto.Id, AttendeeId = userId }; _db.Attendances.Add(attendance); _db.SaveChanges(); return(Ok()); }