Пример #1
0
        public HttpResponseMessage RemoveById(int?id)
        {
            if (id != null)
            {
                if (editService.Retrieve() != null && editService.Retrieve().Count > 0)
                {
                    string idasString = editService.GetCurrentBlogId().ToString();
                    editService.DeleteById(id.GetValueOrDefault());

                    return(new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(idasString)
                    });
                }
            }
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent("Please specify an id.")
                });
            };
            return(null);
        }
Пример #2
0
        public ActionResult Edit(int?id)
        {
            if (id != null)
            {
                ApplicationDbContext context = new ApplicationDbContext();
                var user = context.Users.Find(User.Identity.GetUserId());

                if (user != null && context.BlogDatas.Any(blog => blog.ApplicationUserId == user.Id && blog.BlogDataId == id))
                {
                    var blogdata = context.BlogDatas.Where(blog => blog.ApplicationUserId == user.Id && blog.BlogDataId == id).ToList().Single();

                    List <Element> elements = GenerateElements(blogdata.GalleryModels, blogdata.ImageModels, blogdata.TextModels, blogdata.VideoModels);

                    if (deletetempService.GetCurrentBlogId() == id && deletetempService.Retrieve() != null && deletetempService.Retrieve().Count >= 0)
                    {
                        elements = deletetempService.Retrieve();
                    }
                    else
                    {
                        elements = elements.OrderBy(x => x.position).ToList();
                        deletetempService.Clear();
                        deletetempService.Initialize(elements);
                        deletetempService.SetCurrentBlogId(id.GetValueOrDefault());
                    }



                    var viewmodel = new ExternBlogViewModel {
                        Title = blogdata.Title, Subtitle = blogdata.Subtitle, Elements = elements
                    };


                    return(View(viewmodel));
                }
            }

            return(RedirectToAction("Overview", "Blog"));
        }