示例#1
0
        internal override List <IEvent> ExtractModels(List <DynamicTableEntity> entities)
        {
            var list = new List <IEvent>();

            foreach (var entity in entities)
            {
                IEvent e = EventBase.GetEventFromType((EventType)entity.Properties["Type"].Int32Value.Value);
                if (e != null)
                {
                    e.Id        = entity.Properties["Id"].GuidValue.Value;
                    e.StartTime = entity.Properties["StartTime"].DateTime.Value;
                    e.EndTime   = entity.Properties["EndTime"].DateTime.Value;
                    e.Name      = entity.Properties["Name"].StringValue;
                    e.Contact.Clone(JsonConvert.DeserializeObject <Contact>(entity.Properties["ContactJSON"].StringValue));
                    e.Venue.Clone(JsonConvert.DeserializeObject <Address>(entity.Properties["VenueJSON"].StringValue));

                    var arrangementsJSON = entity.Properties["ArrangementsJSON"].StringValue;
                    if (!string.IsNullOrEmpty(arrangementsJSON))
                    {
                        var arrangements = JsonConvert.DeserializeObject <IEnumerable <Arrangement> >(arrangementsJSON);
                        foreach (var a in arrangements)
                        {
                            var aEntity = new ArrangementEntity(a.Id);
                            a.Clone(aEntity.FetchById().Result);
                            e.Arrangements.Add(a);
                        }
                    }
                    list.Add(e);
                }
            }
            return(list);
        }
示例#2
0
 internal async override Task <IEvent> Save()
 {
     PopulateFromModel(Model);
     foreach (var a in Arrangements)
     {
         var aEntity = new ArrangementEntity(a);
         await aEntity.Save();
     }
     return(await base.Save());
 }
示例#3
0
        internal async override Task <int> Delete()
        {
            if (Arrangements == null)
            {
                //Try fetching from database.
                IEvent e = await FetchById();

                Arrangements = e.Arrangements;
            }
            if (Arrangements != null)
            {
                foreach (var a in Arrangements)
                {
                    var aEntity = new ArrangementEntity(a.Id);
                    await aEntity.Delete();
                }
            }
            return(await base.Delete());
        }