Ejemplo n.º 1
0
        //
        // GET: /Admin/Content/

        public ActionResult Edit(int id)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Where(c => c.Id == id).First();
                return View(content);
            }
        }
Ejemplo n.º 2
0
 public ActionResult AddMusicContent(int id)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Include("MusicContent").Where(c => c.Id == id).First();
         ViewData["contentId"] = id;
         int sortOrder = 0;
         if (content.MusicContent.Count > 0)
             sortOrder = content.MusicContent.Max(c => c.SortOrder);
         return View(new MusicContent{SortOrder = sortOrder+1});
     }
 }
Ejemplo n.º 3
0
        public ActionResult Index(string id)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Include("MusicContent").Where(c => string.IsNullOrEmpty(id) ? c.Id == 1 : c.Name == id).First();

                var menuItems = context.Content.Where(c => c.Id != 1).ToList();
                ViewData["menuItems"] = menuItems;
                ViewData["contentName"] = content.Name;
                ViewData["seoDescription"] = content.SeoDescription;
                ViewData["seoKeywords"] = content.SeoKeywords;

                return View(content);
            }
        }
Ejemplo n.º 4
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Where(c => c.Id == id).First();
         TryUpdateModel(content, new[]
                            {
                                "Name", 
                                "Title", 
                                "MenuTitle", 
                                "PageTitle", 
                                "SortOrder", 
                                "SeoDescription",
                                "SeoKeywords"
                            });
         content.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new {id = content.Name, area=""});
     }
 }
Ejemplo n.º 5
0
        public ActionResult AddMusicContent(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Where(c => c.Id == id).First();
                var mc = new MusicContent();
                if (Request.Files["logo"] != null && !string.IsNullOrEmpty(Request.Files["logo"].FileName))
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Files", Request.Files["logo"].FileName);
                    string filePath = Server.MapPath("~/Content/Files");
                    filePath = Path.Combine(filePath, fileName);
                    Request.Files["logo"].SaveAs(filePath);
                    mc.FileSource = fileName;

                }
                TryUpdateModel(mc, new[] {"Title", "SortOrder"});
                mc.Description = HttpUtility.HtmlDecode(form["Description"]);
                content.MusicContent.Add(mc);
                context.SaveChanges();


                return RedirectToAction("Index", "Home", new {id = content.Name, area = ""});
            }
        }
Ejemplo n.º 6
0
 public ActionResult DeleteMusicContent(int id)
 {
     using (var context = new ContentStorage())
     {
         var mc = context.MusicContent.Include("Content").Where(c => c.Id == id).First();
         var contentName = mc.Content.Name;
         if(!string.IsNullOrEmpty(mc.FileSource))
         {
             IOHelper.DeleteFile("~/Content/Files", mc.FileSource);
             context.DeleteObject(mc);
         }
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { id = contentName, area = "" });
     }
 }