SymbolsController.cs 1.04 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using CWA.CpoOnline.Helpers;
using CWA.CpoOnline.Models;

namespace CWA.CpoOnline.Controllers
{
	[Authorize(Roles = CpoRoles.Admin)]
	public class SymbolsController : Controller
	{
		public ActionResult Index(string id="0")
		{
			ViewBag.ActiveSectorId = id;
			List<SectorViewModel> sectors;

			if (string.IsNullOrWhiteSpace(id) || id.Equals("0"))
			{
				sectors = HardCode.AllSectors;
			}
			else
			{
				sectors = HardCode.AllSectors.Where(s => s.Id.Equals(id, StringComparison.InvariantCultureIgnoreCase)).OrderBy(s => s.Name).ToList();
			}
			var symbols = sectors.SelectMany(sector => sector.Symbols).ToList();
			ViewBag.AllSymbols = symbols;

			return View(HardCode.AllSectors);
        }


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

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

		public async Task<ActionResult> Delete(string id)
		{
			return RedirectToAction("index");
		}

	}
}