Exemplo n.º 1
0
        //
        // GET: /BaseContent/

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string contentUrl = filterContext.RouteData.Values["contentUrl"].ToString();

            if (contentUrl != null)
            {
               
                using (bigs.Models.DataStorage context = new bigs.Models.DataStorage())
                {
                    SiteContent content = Utils.GetContent(contentUrl);

                    if (content == null)
                        throw new HttpException(404, "NotFound");


                    if (content.Language != SystemSettings.CurrentLanguage)
                    {
                        SystemSettings.CurrentLanguage = content.Language;
                    }
                    ViewData["text"] = content.Text;
                    ViewData["contentUrl"] = contentUrl;
                    ViewData["text"] = content.Text;
                    ViewData["title"] = content.Title;
                    ViewData["keywords"] = content.Keywords;
                    ViewData["description"] = content.Description;
                    ViewData["contentName"] = content.Name;
                }
                
            }
            base.OnActionExecuting(filterContext);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
           
            using (DataStorage context = new DataStorage())
            {

                string imageName = Request.Files["image"].FileName;
                if (!string.IsNullOrEmpty(imageName))
                {
                    imageName = Path.GetFileName(imageName);
                    string imagePath = Server.MapPath("~/Content/Objects/" + imageName);
                    Request.Files["image"].SaveAs(imagePath);
                    Request.Files["image"].InputStream.Close();
                    ImageContent imageItem = new ImageContent();
                    imageItem.FileName = imageName;
                    imageItem.Language = SystemSettings.CurrentLanguage;
                    imageItem.Url = Request.Form["url"];
                    context.AddToImageContent(imageItem);
                    context.SaveChanges();
                }

                
                
                //List<ImageContent> images = context.ImageContent.Where(i => i.Language == SystemSettings.CurrentLanguage).Select(i => i).ToList();
                //return View(images);
            }
            Response.Write("<script>window.close()</script>");
            //Response.Redirect("Admin/EditPicture/?contentUrl=" + contentUrl + "&controllerName=" + controllerName);
        }
Exemplo n.º 3
0
 public ActionResult Buttons()
 {
     using (DataStorage context = new DataStorage())
     {
         List<ButtonStatuses> buttons = (from button in context.ButtonStatuses where button.Language == SystemSettings.CurrentLanguage orderby button.SortOrder ascending select button).ToList();
         return View(buttons);
     }
 }
Exemplo n.º 4
0
        //
        // GET: /Languages/

        public ActionResult SetLanguage(string language, string contentController, string contentUrl)
        {
            SystemSettings.CurrentLanguage = language;
            using (DataStorage context = new DataStorage())
            {
                string contentName = context.SiteContent.Where(sc => sc.Url == contentUrl).Select(sc => sc.Name).First();
                string newUrl = context.SiteContent.Where(sc => sc.Name == contentName && sc.Language == language).Select(sc => sc.Url).First();
                return RedirectToAction("Index", contentController, new { contentUrl = newUrl });
            }
        }
Exemplo n.º 5
0
 public ActionResult EditPicture(string contentUrl, string controllerName)
 {
     using (DataStorage context = new DataStorage())
     {
         ViewData["controllerName"] = controllerName;
         ViewData["contentUrl"] = contentUrl;
         List<ImageContent> images = context.ImageContent.Where(i => i.Language == SystemSettings.CurrentLanguage).Select(i => i).ToList();
         return View(images);
     }
 }
Exemplo n.º 6
0
 public static SiteContent GetContent(string contentUrl)
 {
     using (DataStorage context = new DataStorage())
     {
         SiteContent result = context.SiteContent.Where(c => c.Url == contentUrl).Select(c => c).FirstOrDefault();
         if (result == null)
             return result;
         context.Detach(result);
         return result;
     }
 }
Exemplo n.º 7
0
 public static void SetText(string contentUrl, string text, string title, string keywords, string description)
 {
     using (DataStorage context = new DataStorage())
     {
         SiteContent content = context.SiteContent.Where(sc => sc.Url == contentUrl).Select(sc => sc).First();
         content.Text = text;
         content.Title = title;
         content.Keywords = keywords;
         content.Description = description;
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 private static void UpdateApplicationData(string name, string value)
 {
     HttpRuntime.Cache.Remove("ApplicationData_" + name);
     using (DataStorage context = new DataStorage())
     {
         var data = (from appData in context.ApplicationSettings
                     where appData.Name == name
                     select appData).First();
         data.Value = value;
         context.SaveChanges();
     }
 }
Exemplo n.º 9
0
        public ActionResult EditTransfers(string text, string controllerName, string contentUrl)
        {
            Utils.SetText(contentUrl, HttpUtility.HtmlDecode(text), null, null, null);

            using (DataStorage context = new DataStorage())
            {
                string newUrl = context.SiteContent.Where(sc => sc.Name == "Services" && sc.Language == SystemSettings.CurrentLanguage).Select(sc => sc.Url).First();



                return RedirectToAction("Index", controllerName, new { contentUrl = newUrl });
            }
        }
Exemplo n.º 10
0
 private static string GetApplicationData(string name)
 {
     if (HttpRuntime.Cache["ApplicationData_" + name] == null)
     {
         using (DataStorage context = new DataStorage())
         {
             string result = (from data in context.ApplicationSettings
                              where data.Name == name
                              select data.Value).First();
             HttpRuntime.Cache.Insert("ApplicationData_" + name, result, null, DateTime.Now.AddHours(3), Cache.NoSlidingExpiration);
         }
     }
     return HttpRuntime.Cache["ApplicationData_" + name].ToString();
 }
Exemplo n.º 11
0
        public ActionResult EditPicture(FormCollection form)
        {
            using (DataStorage context = new DataStorage())
            {

                string imageName = Request.Files["image"].FileName;
                if (!string.IsNullOrEmpty(imageName))
                {
                    imageName = Path.GetFileName(imageName);
                    string imagePath = Server.MapPath("~/Content/Objects/" + imageName);
                    Request.Files["image"].SaveAs(imagePath);
                    Request.Files["image"].InputStream.Close();
                    ImageContent imageItem = new ImageContent();
                    imageItem.FileName = imageName;
                    imageItem.Language = SystemSettings.CurrentLanguage;
                    imageItem.Url = form["url"];
                    context.AddToImageContent(imageItem);
                    context.SaveChanges();
                }

                List<ImageContent> images = context.ImageContent.Where(i => i.Language == SystemSettings.CurrentLanguage).Select(i => i).ToList();
                return View(images);
            }
        }
Exemplo n.º 12
0
 public ActionResult DeleteSubMenuItem(int id, string redirectUrl)
 {
     using (DataStorage context = new DataStorage())
     {
         SiteContent content = (from c in context.SiteContent where c.Id == id select c).First();
         context.DeleteObject(content);
         context.SaveChanges();
         return Redirect(redirectUrl);
     }
 }
Exemplo n.º 13
0
 public ActionResult AddSubMenuItem(FormCollection form, string redirectUrl, string tName, string tTitle)
 {
     if (!string.IsNullOrEmpty(tName) && !string.IsNullOrEmpty(tTitle))
     {
         using (DataStorage context = new DataStorage())
         {
             SiteContent parent = (from c in context.SiteContent.Include("Parent") where c.Language == SystemSettings.CurrentLanguage && c.Name == "Services" select c).First();
             SiteContent content = new SiteContent();
             content.Name = tName;
             content.Title = tTitle;
             content.Language = SystemSettings.CurrentLanguage;
             content.Url = tTitle;
             content.SortOrder = 4;
             content.Parent = parent;
             context.AddToSiteContent(content);
             context.SaveChanges();
         }
     }
     return Redirect(redirectUrl);
 }
Exemplo n.º 14
0
        public ActionResult UpdateButtonsState(FormCollection form, string redirectUrl)
        {
            using (DataStorage context = new DataStorage())
            {
                if (!string.IsNullOrEmpty(form["enablities"]))
                {
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    Dictionary<string, string> enables = serializer.Deserialize<Dictionary<string, string>>(form["enablities"]);

                    foreach (string key in enables.Keys)
                    {

                        int id = int.Parse(key);
                        ButtonStatuses sButton = (from button in context.ButtonStatuses where button.Id == id select button).First();
                        sButton.SwitchedOn = bool.Parse(enables[key]);
                    }
                    context.SaveChanges();
                }
                List<ButtonStatuses> buttons = (from button in context.ButtonStatuses where button.Language == SystemSettings.CurrentLanguage orderby button.SortOrder ascending select button).ToList();
                return Redirect(redirectUrl);
            }

        }
Exemplo n.º 15
0
        public ActionResult DeletePicture(int id, string contentUrl, string controllerName)
        {
            
            using (DataStorage context = new DataStorage())
            {
                ImageContent image = (from i in context.ImageContent where i.Id == id select i).First();
                string imageName = image.FileName;
                context.DeleteObject(image);
                context.SaveChanges();
                
                string path = Server.MapPath("~/Content/Objects/" + imageName);

                if (!string.IsNullOrEmpty(imageName))
                {
                    //DeleteFileInTheThread(path);
                    System.IO.File.Delete(path);
                }
            }
            return RedirectToAction("EditPicture", "Admin", new { contentUrl = contentUrl });
        }