public StrongJsonResult <ViewDataModel> GetViewData(int?userId)
        {
            using (var db = new MyCalendarDbContext())
            {
                var users = db.Users
                            .Where(u => u.UserId == userId ||
                                   u.UserLinksTo
                                   .Any(l => l.FromUserId == userId))
                            .ToList();

                var data = users
                           .Select(u => new
                {
                    User   = u,
                    Events = u.Events
                })
                           .ToList();

                var viewModels = data
                                 .Select(d => new UserViewModel(d.User, d.Events))
                                 .ToList();

                var model = new ViewDataModel
                {
                    Users         = viewModels,
                    CurrentUserId = userId
                };
                return(StrongJsonResult.From(model));
            }
        }
Example #2
0
        public ActionResult Benamingen(ViewDataModel vdm)
        {
            ViewDataValue vdvP = _dataManager.GetViewDataValue("Personen");
            ViewDataValue vdvO = _dataManager.GetViewDataValue("Organisaties");
            ViewDataValue vdvT = _dataManager.GetViewDataValue("Themas");

            vdvP.StringValue = vdm.Personen;
            _dataManager.UpdateViewDataValue(vdvP);

            vdvO.StringValue = vdm.Organisaties;
            _dataManager.UpdateViewDataValue(vdvO);

            vdvT.StringValue = vdm.Themas;
            _dataManager.UpdateViewDataValue(vdvT);

            //ViewDataValue vdv;
            //foreach(ViewDataValue vdval in vdm.VdvList)
            //{
            //    vdv = _dataManager.GetViewDataValue(vdval.Name);
            //    if (vdv != null)
            //    {
            //        vdv.Name = vdval.Name;
            //        vdv.StringValue = vdval.StringValue;
            //        _dataManager.UpdateViewDataValue(vdv);
            //    }
            //    else
            //    {
            //        _dataManager.AddViewDataValue(vdv);
            //    }
            //}
            return(View());
        }
Example #3
0
        public ActionResult Benamingen()
        {
            ViewDataModel vdm = new ViewDataModel();
            //List<ViewDataValue> VdvList = new List<ViewDataValue>();

            ViewDataValue vdvP = _dataManager.GetViewDataValue("Personen");

            if (vdvP != null)
            {
                vdm.Personen = vdvP.Name;
            }
            else
            {
                vdvP = new ViewDataValue()
                {
                    Name        = "Personen",
                    StringValue = @"Personen"
                };
                _dataManager.AddViewDataValue(vdvP);
                vdm.Personen = vdvP.Name;
            }

            ViewDataValue vdvO = _dataManager.GetViewDataValue("Organisaties");

            if (vdvO != null)
            {
                vdm.Organisaties = vdvO.Name;
            }
            else
            {
                vdvO = new ViewDataValue()
                {
                    Name        = "Organisaties",
                    StringValue = @"Organisaties"
                };
                _dataManager.AddViewDataValue(vdvO);
                vdm.Organisaties = vdvO.Name;
            }

            ViewDataValue vdvT = _dataManager.GetViewDataValue("Themas");

            if (vdvT != null)
            {
                vdm.Themas = vdvT.Name;
            }
            else
            {
                vdvT = new ViewDataValue()
                {
                    Name        = "Themas",
                    StringValue = @"Themas"
                };
                _dataManager.AddViewDataValue(vdvT);
                vdm.Themas = vdvT.Name;
            }
            return(View());
        }
Example #4
0
 public IActionResult Index()
 {
     if (cachingDemoContext.Model.Count() > 0)
     {
         viewDataModel = new ViewDataModel(cachingDemoContext.Model.Count(), cachingDemoContext.ModelData.Count() / cachingDemoContext.Model.Count());
         GetModelsFromCache();
     }
     else
     {
         viewDataModel = new ViewDataModel(0, 0);
     }
     return(View(viewDataModel));
 }
        public ActionResult ByViewModel()
        {
            // ใช้ร่วมกับ class ViewDataModel เพื่อประกาศตัวแปร เก็บค่า
            // แล้วเก็บค่า จาก GetAll...
            // IEnumerable รับค่า จาก List
            // ต้องส่งออกผ่าน  View(data)

            ViewDataModel data = new ViewDataModel();

            data.GetCustomers = GetAllCustomers();
            data.GetProducts  = GetAllProduct();

            return(View(data));  // --->
        }
        public ActionResult Index(string q = null, string hero = null)
        {
            var searchService = new CardSearchService(MvcApplication.CardCache);

            var cards = searchService.Search(q, hero);

            //Getting all the hero cards to create the dropdown menu by code
            //I wanted to avoid hard coding all the hero selections

            var heroes = searchService.GetHeroes();

            // Creating an object with the whole set of cards and heroes to pass to the view
            var viewData = new ViewDataModel();

            viewData.CardsData  = cards;
            viewData.HeroesData = heroes;

            //Return the new object to the view
            return(View(viewData));
        }
Example #7
0
        public IActionResult ProcessModels([Bind(Prefix = "ModelInput")] ModelInput modelInput)
        {
            var numModels    = modelInput.NumModels;
            var numVariables = modelInput.NumVariables;

            viewDataModel = new ViewDataModel(numModels, numVariables);
            if (cachingDemoContext.Model.Count() != numModels)
            {
                ProcessModelData(numModels, numVariables);
            }
            else
            {
                if (cachingDemoContext.ModelData.Count() / cachingDemoContext.Model.Count() != numVariables)
                {
                    ProcessModelData(numModels, numVariables);
                }
            }

            GetModelsFromCache();

            return(View("Index", viewDataModel));
        }
        public PartialViewResult _partialOne(ViewDataModel one)
        {
            ViewDataValue vdvP = dMgr.GetViewDataValue("Personen");
            ViewDataValue vdvO = dMgr.GetViewDataValue("Organisaties");
            ViewDataValue vdvT = dMgr.GetViewDataValue("Themas");

            if (vdvP != null)
            {
                one.Personen = vdvP.StringValue;

                //ViewBag.Personen = vdvP.StringValue;
                ViewBag.Organisaties = vdvO.StringValue;
                ViewBag.Themas       = vdvT.StringValue;
            }
            else
            {
                ViewBag.Personen     = "Personen";
                ViewBag.Organisaties = "Organisaties";
                ViewBag.Themas       = "Themas";
            }

            return(PartialView("~/Views/Home/_partialOne.cshtml", one));
            //return PartialView();
        }
        public async Task <ActionResult> GetProcessFieldDataByVersions(string name, string version)
        {
            _Connection.DatabaseConnection();         //Estabeleçer a ligação com a base de dados;
            var database = _Connection.GetDatabase(); //Obter a ligação com a base de dados;

            _Metadata.SetDatabase(database);
            _Data.SetDatabase(database);

            /*
             * Paginação - Fase de obtenção do nº de página;
             */
            string pageNumber = Request.Query["Page"];

            if (string.IsNullOrEmpty(pageNumber))
            {
                pageNumber = 1.ToString();
            }

            int pageIndex = Convert.ToInt32(pageNumber);

            ViewBag.ProcessName    = name;
            ViewBag.ProcessVersion = version;
            ViewBag.PageNumber     = pageNumber;

            List <string> processIdList      = new List <string>(); //Armazena a lista de id´s do processo nas diferentes versões;
            List <int>    processVersionList = new List <int>();    //Armazena as versões correspondentes ao id do processo;

            //Recupera versões anteriores do processo se as mesmas existirem;
            if (int.Parse(version) >= 1)
            {
                for (int j = int.Parse(version); j >= 1; j--)
                {
                    processIdList.Add(_Metadata.GetProcessByVersion(name, j).Id);
                    processVersionList.Add(j);
                }
            }

            List <ViewDataModel> viewDataModelList = new List <ViewDataModel>(); //Lista de ViewDataModels, para display da dados;

            //Ciclo que percorre as diferentes combinações de {Process Id - Version - Branch}
            for (int i = 0; i < processIdList.Count; i++)
            {
                List <DataModel> dataModelList = _Data.GetDataModelByProcessId(processIdList.ElementAt(i));

                foreach (var dataModel in dataModelList)
                {
                    //É criado o modelo de dados do tipo ViewDataModel;
                    ViewDataModel modelToDisplay = new ViewDataModel()
                    {
                        ObjectId       = _Data.GetObjectId(processIdList.ElementAt(i), processVersionList.ElementAt(i), dataModel.ProcessBranch, dataModel.Data),
                        ProcessId      = processIdList.ElementAt(i),
                        ProcessVersion = processVersionList.ElementAt(i),
                        ProcessBranch  = dataModel.ProcessBranch,
                        CreationDate   = dataModel.Date,
                        Data           = dataModel.Data
                    };
                    viewDataModelList.Add(modelToDisplay); //Adiciona-se à lista de ViewDataModel o modelo criado;
                }
            }
            _SetPagination.SetNumberOfModelsByPage(4);
            Dictionary <int, List <ViewDataModel> > modelsToDisplay = _SetPagination.SetModelsByPage(viewDataModelList);

            int NumberOfPages = modelsToDisplay.Count();

            ViewBag.NumberOfPages = NumberOfPages;

            if (modelsToDisplay.Count == 0)
            {
                List <ViewDataModel> auxViewDataModelList = new List <ViewDataModel>();
                ViewDataModel        emptyModel           = new ViewDataModel()
                {
                    ObjectId       = null,
                    ProcessId      = null,
                    ProcessVersion = 0,
                    ProcessBranch  = null,
                    CreationDate   = DateTime.UtcNow.Date,
                    Data           = null
                };
                auxViewDataModelList.Add(emptyModel);
                return(await Task.Run(() => View("GetProcessFieldDataByVersions", auxViewDataModelList)));
            }

            return(await Task.Run(() => View("GetProcessFieldDataByVersions", modelsToDisplay[pageIndex])));
        }