예제 #1
0
        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);
        }
예제 #2
0
        public HttpResponseMessage PostDeleteLoveStory([FromBody] dynamic data)
        {
            HttpResponseMessage response = null;

            try
            {
                OurLoveStory story = new OurLoveStory();
                var          jObj  = (JObject)data;

                story = Services.GetInstance.GetLoveStoryByLoveStoryID(jObj["OurStoryID"].Value <int>());

                Services.GetInstance.DeleteLoveStory(story);
                response = this.Request.CreateResponse(HttpStatusCode.Created, new { Created = 200, Message = "Image has been Deleted Successfully!", storyID = story.OurStoryID });
            }
            catch (Exception ex)
            {
                response = this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
            }

            return(response);
        }