Example #1
0
        public ActionResult ZoneTypeSelectAll([DataSourceRequest] DataSourceRequest request)
        {
            BL.ZoneTypes    blZoneTypes = new BL.ZoneTypes();
            List <ZoneType> model       = blZoneTypes.SelectAll();

            return(Json(model.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult Index()
        {
            BL.Zones     blZone      = new BL.Zones();
            BL.ZoneTypes blZoneTypes = new BL.ZoneTypes();
            //Get the ZoneTypes and Zones
            List <ZoneType> zoneTypes = blZoneTypes.SelectAll();
            List <Zone>     zones     = blZone.SelectAll();

            List <ZoneViewModel> model = new List <ZoneViewModel>();

            //Merge the two into a view model
            foreach (Zone zone in zones)
            {
                ZoneViewModel vm = new ZoneViewModel
                {
                    IsActive           = zone.IsActive,
                    Name               = zone.Name,
                    ZoneID             = (int)zone.ZoneID,
                    SelectedZoneTypeID = zone.ZoneTypeID,
                    ZoneTypeName       = zoneTypes.Where(c => c.ZoneTypeID == zone.ZoneTypeID).Select(c => c.Name).FirstOrDefault()
                };
                model.Add(vm);
            }

            //Place in Viewbag for use in template
            TempData["ZT"]      = zoneTypes;
            ViewBag.vbZoneTypes = zoneTypes;
            return(View(model));
        }