Exemplo n.º 1
0
 public ActionResult Details(EquipmentPointRoleViewModel Model, string pointId)
 {
     if (!string.IsNullOrEmpty(pointId))
     {
         ViewBag.AccessToken = _buildingService.GetAccessToken(Model.SelectedCompany);
         ViewBag.pointUrl = _buildingService.APIBaseUrl.AppendPathSegment("building/points").AppendPathSegment(pointId).ToString();
     }
     return View();
 }
Exemplo n.º 2
0
        public ActionResult Index(string selectedCompany, string selectedEquipmentType, string selectedRoleType)
        {
            var viewModel = new EquipmentPointRoleViewModel();

            // Retrieve Companies
            var companies = _buildingService.GetCompanies().ToList();
            var companieslist = companies.Select(comp => new SelectListItem
            {
                Value = comp.Id,
                Text = comp.Name
            }).ToList();
            viewModel.Companies = companieslist;
            viewModel.SelectedCompany = selectedCompany;

            // Retrieve Available Equipment Type and Role
            var types = _buildingService.GetEquipmentTypes().ToList();
            var listItem = types.Select(type => new SelectListItem
            {
                Value = type.Id,
                Text = type.Name
            }).ToList();
            viewModel.EquipmentTypes = listItem;
            viewModel.SelectedEquipmentType = selectedEquipmentType;

            // If an equipmentType has been selected populate the Role accordenly
            var roles = new List<SelectListItem>();
            if (!string.IsNullOrEmpty(selectedEquipmentType))
                foreach (var item in types.First(t => t.Id == selectedEquipmentType).PointRoleTypes)
                    roles.Add(new SelectListItem { Value = item.Id, Text = item.Id });
            viewModel.RoleTypes = roles;
            viewModel.SelectedRoleType = selectedRoleType;

            // Retrieve data for the partial view
            var company = companies.FirstOrDefault(c => c.Id == selectedCompany);
            viewModel.Equipment = _retrievePointsStatus(company, selectedEquipmentType, selectedRoleType);

            return View(viewModel);
        }