コード例 #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 override IEvent ConvertToModel()
        {
            IEvent e = EventBase.GetEventFromType((EventType)Type);

            if (e != null)
            {
                e.Id        = Id;
                e.StartTime = StartTime;
                e.EndTime   = EndTime;
                e.Name      = Name;
                e.Contact.Clone(Contact);
                e.Arrangements.AddRange(Arrangements);
            }
            return(e);
        }
コード例 #3
0
 public void CopyRequestToProject(IProject p)
 {
     p.Id     = Id;
     p.Name   = Name;
     p.UserId = UserId;
     if (Events != null)
     {
         foreach (var e in Events)
         {
             IEvent ev = EventBase.GetEventFromType(e.Type);
             e.CopyRequestToEvent(ev);
             p.Events.Add(ev);
         }
     }
 }
コード例 #4
0
        private IEvent CreateEvent(EventType type)
        {
            IEvent e = EventBase.GetEventFromType(type);

            e.Name      = "Wedding Sample";
            e.StartTime = DateTime.Today.AddMonths(1);
            e.EndTime   = e.StartTime.AddHours(6);
            e.Contact.Clone(CreateContact());
            e.Venue.Clone(e.Contact.Address);
            var     a      = CreateArrangement();
            IVendor vendor = CreateVendor(VendorType.Photographer);

            var h = new VendorProcessor(vendor);
            var s = h.Create().Result;

            a.Vendor = s.Data;
            e.Arrangements.Add(a);

            return(e);
        }
コード例 #5
0
        public async Task <HttpResponseMessage> Create(EventRequest req)
        {
            IEvent e = EventBase.GetEventFromType(req.Type);

            if (e != null)
            {
                req.CopyRequestToEvent(e);
                var ep  = new EventProcessor(e);
                var res = await ep.Create();

                if (res != null && res.Success)
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(new { Id = res.Data.Id.ToString() }))
                    });
                }
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }
コード例 #6
0
        public async Task <HttpResponseMessage> DeleteEvents(ProjectRequest req)
        {
            if (req.Id != Guid.Empty)
            {
                if (req.Events != null && req.Events.Any())
                {
                    var           ep   = new ProjectProcessor(req.Id);
                    List <IEvent> list = new List <IEvent>();
                    foreach (var ar in req.Events)
                    {
                        IEvent e = EventBase.GetEventFromType(ar.Type);
                        e.Id = ar.Id;
                        list.Add(e);
                    }
                    await ep.DeleteEvents(list);

                    return(new HttpResponseMessage()
                    {
                        StatusCode = System.Net.HttpStatusCode.OK
                    });
                }
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }