示例#1
0
        public List <EntityStoreItem> GetEntities(int skip, int take)
        {
            bool withPaging = (take >= 0);

            using (var uow = this.GetUnitOfWork())
                using (ScheduleManager scheduleManager = new ScheduleManager())
                {
                    if (withPaging)
                    {
                        return(scheduleManager.GetAllSchedules().Select(r => new EntityStoreItem()
                        {
                            Id = r.Id, Title = r.Id.ToString()
                        }).Skip(skip).Take(take).ToList());
                    }
                    else
                    {
                        return(scheduleManager.GetAllSchedules().Select(r => new EntityStoreItem()
                        {
                            Id = r.Id, Title = r.Id.ToString()
                        }).ToList());
                    }
                }
        }
        public bool DeleteBookingEvent(E.BookingEvent deleteEvent)
        {
            Contract.Requires(deleteEvent != null);
            Contract.Requires(deleteEvent.Id >= 0);

            using (ScheduleManager sManager = new ScheduleManager())
            {
                bool deleteSchedules = sManager.RemoveAllSchedulesByEvent(deleteEvent.Id);

                if (deleteSchedules)
                {
                    using (IUnitOfWork uow = this.GetUnitOfWork())
                    {
                        IRepository <E.BookingEvent> repo = uow.GetRepository <E.BookingEvent>();
                        deleteEvent = repo.Reload(deleteEvent);
                        repo.Delete(deleteEvent);
                        uow.Commit();
                    }
                }
            }

            return(true);
        }