public bool deleteSportEvent(int id) { using (var uow = new UnitOfWork()) { var sportEventRepo = uow.GetRepository <SportEvent>(); var sportEventSerivce = new SportEventService(); var sportEvent = sportEventRepo.GetById(id); if (sportEvent == null) { return(false); } else { if (sportEvent.Attendees != null) { foreach (var aten in sportEvent.Attendees) { aten.ParticipatedSportEvents.Remove(sportEvent); } sportEvent.Attendees = null; } uow.SaveChanges(); sportEventRepo.Delete(id); uow.SaveChanges(); return(true); } } }
public IEnumerable <SportEventDTO> GetByPage(int pageSize, int pageNumber) { var sportEventService = new SportEventService(); var sportEvents = sportEventService.getAllEvents(); var totalCount = sportEvents.Count(); var totalPages = Math.Ceiling((double)totalCount / pageSize); sportEvents = sportEvents.OrderByDescending(s => s.Date); var sportsev = sportEvents.Skip((pageNumber - 1) * pageSize) .Take(pageSize) .ToList(); return(sportsev); }