示例#1
0
        public async Task <HttpResponseMessage> UpdateArrangements(EventRequest req)
        {
            if (req.Arrangements != null && req.Arrangements.Any())
            {
                foreach (var ar in req.Arrangements)
                {
                    var ep = new ArrangementProcessor(ar);
                    await ep.Update();
                }

                return(new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.OK
                });
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }
示例#2
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));
        }
示例#3
0
        public async Task <HttpResponseMessage> DeleteArrangements(EventRequest req)
        {
            if (req.Id != Guid.Empty)
            {
                if (req.Arrangements != null && req.Arrangements.Any())
                {
                    var ep = new EventProcessor(req.Id);
                    List <IArrangement> list = new List <IArrangement>();
                    foreach (var ar in req.Arrangements)
                    {
                        list.Add(ar);
                    }
                    await ep.DeleteArrangements(list);

                    return(new HttpResponseMessage()
                    {
                        StatusCode = System.Net.HttpStatusCode.OK
                    });
                }
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }
示例#4
0
        public async Task <HttpResponseMessage> Delete(EventRequest req)
        {
            if (req.Id != Guid.Empty)
            {
                var ep = new EventProcessor(req.Id);
                var e  = await ep.Delete();

                if (e > 0)
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(Convert.ToBoolean(e).ToString()),
                        StatusCode = System.Net.HttpStatusCode.OK
                    });
                }
                else
                {
                    return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound));
                }
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }