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); }
public HttpResponseMessage PostNewLoveStory([FromBody] dynamic data) { HttpResponseMessage response = null; try { OurLoveStory model = new OurLoveStory(); EntityImage image = new EntityImage(); var jObj = (JObject)data; model.Title1 = jObj["Title1"].Value <string>(); model.Title2 = jObj["Title2"].Value <string>(); model.Content = jObj["Content"].Value <string>(); model.CommentBy = jObj["CommentBy"].Value <string>(); model.PublishDate = jObj["PublishDate"].Value <string>(); model.SpecialComment = jObj["SpecialComment"].Value <string>(); model.TemplateId = jObj["TemplateId"].Value <int>(); //model.ImageUrl = jObj["ImageUrl"].Value<string>(); model.OurStoryID = Services.GetInstance.InsertLoveStory(model); image.EntityID = model.OurStoryID; image.SectionID = 3; image.Url = jObj["ImageUrl"].Value <string>(); Services.GetInstance.InsertEntityImage(image); 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); }
public HttpResponseMessage PostDeleteImage([FromBody] dynamic data) { HttpResponseMessage response = null; try { EntityImage image = new EntityImage(); var jObj = (JObject)data; image = Services.GetInstance.GetEntityImageByImageID(jObj["EntityImageID"].Value <int>()); Services.GetInstance.DeleteEntityImage(image); response = this.Request.CreateResponse(HttpStatusCode.Created, new { Created = 200, Message = "Image has been Deleted Successfully!", ImageID = image.EntityImageID }); } catch (Exception ex) { response = this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex); } return(response); }