Example #1
0
        // GET: Co2Roadmap
        public ActionResult Index()
        {
            try
            {
                Co2RoadmapModel model = new Co2RoadmapModel();
                AgentBase       ABase = new AgentBase();
                DatabaseContext dbx   = ABase.GetContext();

                ViewBag.Is_Reco3_Unkown        = User.IsInRole(EnumExtensions.GetDisplayName(UserRole.Role_Reco3_Unkown));
                ViewBag.Is_Reco3_Pending       = User.IsInRole(EnumExtensions.GetDisplayName(UserRole.Role_Reco3_Pending));
                ViewBag.Is_Reco3_Administrator = User.IsInRole(EnumExtensions.GetDisplayName(UserRole.Role_Reco3_Administrator));
                ViewBag.Is_Reco3_Simulator     = User.IsInRole(EnumExtensions.GetDisplayName(UserRole.Role_Reco3_Simulator));
                ViewBag.Is_Reco3_Guest         = User.IsInRole(EnumExtensions.GetDisplayName(UserRole.Role_Reco3_Guest));

                model.Co2Roadmap = dbx.RoadmapGroups.ToList().FirstOrDefault();
                if (model.Co2Roadmap == null)
                {
                    model.Co2Roadmap = new RoadmapGroup();
                    dbx.RoadmapGroups.Add(model.Co2Roadmap);
                    model.ReadOnly = true;
                    dbx.SaveChanges();
                }
                return(View(model));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(View());
        }
Example #2
0
 public ActionResult Edit(int id = 0)
 {
     if (id == -1)
     {
         Co2RoadmapModel model = new Co2RoadmapModel();
         model.ReadOnly   = false;
         model.Co2Roadmap = new RoadmapGroup();
         return(View(model));
     }
     else
     {
         AgentBase       ABase = new AgentBase();
         DatabaseContext dbx   = ABase.GetContext();
         RoadmapGroup    job   = dbx.RoadmapGroups.Include("Roadmaps").Where(x => x.RoadmapGroupId == id).First();
         if (job != null)
         {
             Co2RoadmapModel model = new Co2RoadmapModel();
             model.Co2Roadmap = job;
             model.ReadOnly   = (job.ConvertToVehicleInput_Status != Reco3_Enums.ConvertToVehicleInputStatus.Pending);
             return(View(model));
         }
     }
     return(Index());
 }