Beispiel #1
0
        public void SetAllByWorkshopSet(List <Workshop> list, int workshopSet)
        {
            var updatedList = list
                              .Select(x => { x.LastUpdated = DateTime.Now; return(x); })
                              .Select(x => { x.WorkShopSetName = WorkshopSetTable.Get(x.WorkShopSetId).Name; return(x); })
                              .ToList();

            if (list.Count > 0)
            {
                helpsDatabase.Database.Table <Workshop>().Delete(x => x.WorkShopSetId == workshopSet);
                helpsDatabase.Database.InsertAll(updatedList);
            }
        }
        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);
        }
Beispiel #3
0
 static Db()
 {
     User = new UserTable();
     WorkshopSet = new WorkshopSetTable();
 }