public IActionResult Delete(int id) { User _userDb = _userRepository.GetSingle(id); if (_userDb == null) { return(new NotFoundResult()); } else { IEnumerable <Attendee> _attendees = _attendeeRepository.FindBy(a => a.UserId == id); IEnumerable <Schedule> _schedules = _scheduleRepository.FindBy(s => s.CreatorId == id); foreach (var attendee in _attendees) { _attendeeRepository.Delete(attendee); } foreach (var schedule in _schedules) { _attendeeRepository.DeleteWhere(a => a.ScheduleId == schedule.Id); _scheduleRepository.Delete(schedule); } _userRepository.Delete(_userDb); _userRepository.Commit(); return(new NoContentResult()); } }
public async Task RemoveUserAttendeesAsync(int id) { var attendees = await _attendeeRepository.FindByAsync(a => a.UserId == id); foreach (var attendee in attendees) { _attendeeRepository.Delete(attendee); } }
public ActionResult Delete(int attendeeid) { try { rep.Delete(attendeeid); return(Ok()); } catch (Exception) { throw; } }