Пример #1
0
        public HttpResponseMessage UploadImage()
        {
            var httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFormPageId = httpRequest.Form["pageId"];

            if (httpRequest.Form["subPageId"] != null || postedFormSubPageId != "undefined")
            {
                postedFormSubPageId = httpRequest.Form["subPageId"];
            }

            var postedFormUrl         = httpRequest.Form["imageUrl"];
            var postedBackgroundImage = httpRequest.Form["backgroundImage"];
            var postedFile            = httpRequest.Files["imageUrl"];

            if (postedFormUrl != null && postedFile == null)
            {
                var fireBaseUrl = postedFormUrl;
                var pageId      = Int32.Parse(postedFormPageId);
                var bgImage     = postedBackgroundImage;

                if (postedFormSubPageId != null || postedFormSubPageId != "undefined")
                {
                    subPageId = Int32.Parse(postedFormSubPageId);
                }



                //Save to DB
                using (NewWebContent1 db = new NewWebContent1())
                {
                    Models.WebContent uploadImage = new Models.WebContent()
                    {
                        ImageUrl        = fireBaseUrl,
                        PageId          = pageId,
                        SubPageId       = subPageId,
                        backgroundImage = fireBaseUrl
                                          //height = "500px",
                                          //backgroundRepeat = "no-repeat"
                    };
                    db.WebContents.Add(uploadImage);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException e)
                    {
                        var newException = new FormattedDbEntityValidationException(e);
                        throw newException;
                    }
                }
            }
            return(Request.CreateResponse(HttpStatusCode.Created));
        }
Пример #2
0
        public HttpResponseMessage UploadAudio()
        {
            var httpRequest = HttpContext.Current.Request;
            //Upload Audio
            var postedFormPageId = httpRequest.Form["pageId"];

            var postedFormColumnId = httpRequest.Form["columnId"];

            var postedFormUrl = httpRequest.Form["audioUrl"];

            var postedFile = httpRequest.Files["audioUrl"];

            if (postedFormUrl != null && postedFile == null)
            {
                var fireBaseUrl = postedFormUrl;
                var pageId      = Int32.Parse(postedFormPageId);
                var columnId    = Int32.Parse(postedFormColumnId);



                //Save to DB
                using (NewWebContent1 db = new NewWebContent1())
                {
                    Models.WebContent uploadAudio = new Models.WebContent()
                    {
                        AudioUrl = fireBaseUrl,
                        PageId   = pageId,
                        ColumnId = columnId,
                    };
                    db.WebContents.Add(uploadAudio);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException e)
                    {
                        var newException = new FormattedDbEntityValidationException(e);
                        throw newException;
                    }
                }
            }



            return(Request.CreateResponse(HttpStatusCode.Created));
        }
        public WebsiteTemplateProject.Models.WebContent UpsertSubContent(Models.WebContent webContent, NewWebContent1 db)
        {
            using (db)
            {
                if (webContent != null)
                {
                    if (webContent.Id == default(int))
                    {
                        db.WebContents.Add(webContent);
                    }
                    else
                    {
                        db.Entry(webContent).State = EntityState.Modified;
                    }


                    db.SaveChanges();
                    return(webContent);
                }
                else
                {
                    return(webContent);
                }
            }
        }
        public List <Models.WebContent> GetWebContentByPageIdAndSubPageId(int pageId, int subPageId, NewWebContent1 db)
        {
            List <Models.WebContent> webContentByPageIdAndSubId = new List <Models.WebContent>();

            //First adds all content to list
            foreach (var webContent in db.WebContents)
            {
                webContentByPageIdAndSubId.Add(webContent);
            }



            //Removes any content that doesn't match both page id and sub page id
            foreach (var webContent in webContentByPageIdAndSubId.ToList())
            {
                //Remove any content that doesn't have a page id or sub id
                if (webContent.PageId == null || webContent.SubPageId == null)
                {
                    webContentByPageIdAndSubId.Remove(webContent);
                }


                //If page or subpage id is not null
                if (webContent.PageId != null && webContent.SubPageId != null)
                {
                    //Remove content if pageid doesn't equal page id
                    if (webContent.PageId != pageId)
                    {
                        webContentByPageIdAndSubId.Remove(webContent);
                    }
                    //Remove content if pageid doesn't equal page id

                    if (webContent.SubPageId != subPageId)
                    {
                        webContentByPageIdAndSubId.Remove(webContent);
                    }
                }
            }

            //Return list ordered by Id
            return(webContentByPageIdAndSubId.OrderBy(x => x.Id).ToList());
        }
 public SubContentService(NewWebContent1 context)
 {
     _context = context;
 }
Пример #6
0
        public HttpResponseMessage UploadImage()
        {
            var httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFormPageId   = httpRequest.Form["pageId"];
            var postedFormColumnId = httpRequest.Form["columnId"];


            var postedFormUrl = httpRequest.Form["imageUrl"];
            // var postedBackgroundImage = httpRequest.Form["backgroundImage"];
            var postedFile     = httpRequest.Files["imageUrl"];
            var postedUrl400px = httpRequest.Form["body"];


            if (postedFormUrl != null && postedFile == null)
            {
                var fireBaseUrl = postedFormUrl;
                var pageId      = Int32.Parse(postedFormPageId);
                var columnId    = Int32.Parse(postedFormColumnId);
                //var bgImage = postedBackgroundImage;



                //Save to DB
                using (NewWebContent1 db = new NewWebContent1())
                {
                    Models.WebContent uploadImage = new Models.WebContent()
                    {
                        //ImageUrl = fireBaseUrl,
                        PageId        = pageId,
                        ColumnId      = columnId,
                        animationName = "none",



                        backgroundImage = fireBaseUrl
                    };
                    db.WebContents.Add(uploadImage);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException e)
                    {
                        var newException = new FormattedDbEntityValidationException(e);
                        throw newException;
                    }
                }
            }

            if (postedUrl400px != null && postedFormUrl == null)
            {
                var fireBaseUrl = postedUrl400px;
                var pageId      = Int32.Parse(postedFormPageId);
                var columnId    = Int32.Parse(postedFormColumnId);
                //var bgImage = postedBackgroundImage;

                //Save to DB
                using (NewWebContent1 db = new NewWebContent1())
                {
                    Models.WebContent uploadImage = new Models.WebContent()
                    {
                        //ImageUrl = fireBaseUrl,
                        PageId   = pageId,
                        ColumnId = columnId,



                        Body = fireBaseUrl
                    };
                    db.WebContents.Add(uploadImage);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException e)
                    {
                        var newException = new FormattedDbEntityValidationException(e);
                        throw newException;
                    }
                }
            }
            return(Request.CreateResponse(HttpStatusCode.Created));
        }