Ejemplo n.º 1
0
        public async Task <IActionResult> Result([FromQuery] string link, [FromServices] AnalyzingService analyzer)
        {
            string screenName = link.Replace(@"https://vk.com/", string.Empty);
            var    users      = await VkApi.Users.GetAsync(new[] { screenName }, ProfileFields.Photo100);

            var user     = users[0];
            var response = VkApi.Call(
                "execute.getUserInfo",
                new VkNet.Utils.VkParameters(new Dictionary <string, string>
            {
                ["id"] = user.Id.ToString()
            }));

            var fetchedUser = JsonConvert.DeserializeObject <FetchedResponse>(response.RawJson).Response;

            fetchedUser.Wall.Count = 300;
            fetchedUser.Wall.Items = fetchedUser.Wall.Items.Take(300).ToArray();

            var result = analyzer.Analyze(fetchedUser);

            ViewData["Name"]        = $"{user.FirstName} {user.LastName}";
            ViewData["FacultyName"] = result.First().Key.ToString();
            ViewData["FacultyLink"] = "https://utmn.ru";
            ViewData["AvatarUrl"]   = user.Photo100;
            return(View("Views/Result.cshtml", result));
        }
Ejemplo n.º 2
0
 public IActionResult Fetched([FromServices] AnalyzingService service)
 {
     if (!service.IsFetchingCompleted)
     {
         return(Ok("Fetching is not completed"));
     }
     return(Json(service.Users));
 }