ChartController.cs 1.93 KB
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using CWA.CpoOnline.Helpers;

namespace CWA.CpoOnline.Controllers
{
    [Authorize]
    public class ChartController : Controller
    {
        // GET: Chart
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult One()
        {
            return View("index");
        }

        public ActionResult Two()
        {
            return View();
        }

        [HttpPost]
        [AllowAnonymous]
        public ActionResult SaveImage(HttpPostedFileBase file)
        {
            if (file.ContentLength > 0)
            {
                var fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Content/charts"), fileName);
                file.SaveAs(path);
            }
            return RedirectToAction("Index");
        }

        public ActionResult WideModeToggle()
        {
            CurrentUser.Settings.IsWideMode = !CurrentUser.Settings.IsWideMode;
            var returnUrl = Request?.UrlReferrer?.PathAndQuery;
            return RedirectToLocal(returnUrl);
        }

        public ActionResult Display(string symbol, string layout = "")
        {
            ViewBag.layout = layout;

            foreach (var sector in HardCode.AllSectors)
            {
                foreach (var symbolI in sector.Symbols)
                {
                    if (symbolI.Symbol == symbol)
                    {
                        return View(symbolI);
                    }
                }
            }
            return View();
        }

        private ActionResult RedirectToLocal(string returnUrl)
        {
            if (Url.IsLocalUrl(returnUrl))
            {
                return Redirect(returnUrl);
            }
            return RedirectToAction("Index", "Home");
        }

    }
}