示例#1
0
        public HttpResponseMessage PostNewEvent([FromBody] dynamic data)
        {
            HttpResponseMessage response = null;

            try
            {
                OurEvent model = new OurEvent();

                var jObj = (JObject)data;

                model.Title         = jObj["Title"].Value <string>();
                model.EventLocation = jObj["EventLocation"].Value <string>();
                model.EventContent  = jObj["EventContent"].Value <string>();
                string   urlcollection = jObj["eventImageUrl"].Value <string>();
                string[] values        = urlcollection.Split(',').Select(sValue => sValue.Trim()).ToArray();
                model.OurEventID = Services.GetInstance.InsertOurEvent(model);
                foreach (var item in values)
                {
                    EntityImage img = new EntityImage();
                    img.EntityID  = model.OurEventID;
                    img.SectionID = 2;
                    img.Url       = item;

                    Services.GetInstance.InsertEntityImage(img);
                }
                response = this.Request.CreateResponse(HttpStatusCode.Created, new { Created = 200, Message = "Data has been Posted successfully!" });
            }
            catch (Exception ex)
            {
                response = this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
            }

            return(response);
        }
示例#2
0
        public HttpResponseMessage PostDeleteEvent([FromBody] dynamic data)
        {
            HttpResponseMessage response = null;

            try
            {
                OurEvent events = new OurEvent();
                var      jObj   = (JObject)data;

                events = Services.GetInstance.GetOurEventByID(jObj["EventID"].Value <int>());

                Services.GetInstance.DeleteEvent(events);
                response = this.Request.CreateResponse(HttpStatusCode.Created, new { Created = 200, Message = "Image has been Deleted Successfully!", eventid = events.OurEventID });
            }
            catch (Exception ex)
            {
                response = this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
            }

            return(response);
        }