Beispiel #1
0
        public async Task <bool> SetAll(List <SessionBooking> list, bool?Current)
        {
            var updatedList = list
                              .Select(x => { x.LastUpdated = DateTime.Now; return(x); })
                              .ToList();

            if (Current.HasValue)
            {
                foreach (var item in list)
                {
                    if (NotificationTable.GetAllSessionNotifications(item.SessionId).Count == 0)
                    {
                        NotificationTable.InsertAll(NotificationService.DefaultWorkshopNotifications, item.SessionId,
                                                    item.StartDate);
                    }
                }

                foreach (var item in list)
                {
                    helpsDatabase.Database.Table <SessionBooking>().Delete(x => x.SessionId == item.SessionId);
                }

                if (Current.Value)
                {
                    helpsDatabase.Database.Table <SessionBooking>().Delete(x => x.EndDate > DateTime.Now);
                }
                else
                {
                    helpsDatabase.Database.Table <SessionBooking>().Delete(x => x.EndDate < DateTime.Now);
                }
            }
            helpsDatabase.Database.RunInTransaction(() => { helpsDatabase.Database.InsertAll(updatedList); });
            return(true);
        }
        public async Task <bool> SetAll(List <WorkshopBooking> list, bool?Current)
        {
            var updatedList = list
                              .Select(x => { x.LastUpdated = DateTime.Now; return(x); })
                              .Select(x =>
            {
                var set = WorkshopSetTable.Get(x.WorkShopSetID);
                if (set != null)
                {
                    x.WorkShopSetName = set.Name;
                }
                return(x);
            })
                              .ToList();

            if (Current.HasValue)
            {
                foreach (var item in list)
                {
                    if (NotificationTable.GetAllWorkshopNotifications(item.workshopId).Count == 0)
                    {
                        NotificationTable.InsertAll(NotificationService.DefaultWorkshopNotifications, item.workshopId,
                                                    item.starting);
                    }
                }

                foreach (var item in list)
                {
                    helpsDatabase.Database.Table <WorkshopBooking>().Delete(x => x.workshopId == item.workshopId);
                }
                if (Current.Value)
                {
                    helpsDatabase.Database.Table <WorkshopBooking>().Delete(x => x.ending > DateTime.Now);
                }
                else
                {
                    helpsDatabase.Database.Table <WorkshopBooking>().Delete(x => x.ending < DateTime.Now);
                }
            }
            helpsDatabase.Database.RunInTransaction(() => { helpsDatabase.Database.InsertAll(updatedList); });

            return(true);
        }