Example #1
0
        public async Task <IActionResult> Index()
        {
            var user = await GetCurrentUserAsync();

            var userId = user?.Id;

            List <ThingViewModel> list;
            WebRequest            request = WebRequest.Create(_configuration.GetValue <string>("BackendUrl") + "api/list/" + userId);

            request.Method = "Get";

            using (var s = request.GetResponse().GetResponseStream())
            {
                using (var sr = new StreamReader(s))
                {
                    var contributorsAsJson = sr.ReadToEnd();
                    list = JsonConvert.DeserializeObject <List <ThingViewModel> >(contributorsAsJson);
                }
            }

            ListInfoViewModel model = new ListInfoViewModel {
                userId = userId, things = list
            };

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> ListInfo()
        {
            var model = new ListInfoViewModel();

            using (var context = await createSiteContext())
            {
                // Retrieving lists of the target web using Microsoft Graph
                var web = await context.Web.GetAsync(w => w.Title,
                                                     w => w.Lists.QueryProperties(l => l.Id, l => l.Title, l => l.Description));

                var lists = (from l in context.Web.Lists
                             orderby l.Title descending
                             select l);

                // Retrieving lists of the target web using SPO REST
                // var web = await context.Web.GetAsync(w => w.Title, w => w.Lists.Include(l => l.Title, l => l.Id));
                // var lists = web.Lists;

                model.SiteTitle = web.Title;
                model.Lists     = lists.ToList();
            }

            return(View("ListInfo", model));
        }