Esempio n. 1
0
        // GET: Meetings/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                ViewData["NotFound"] = "The requested meeting is no longer available";
                return(View("~/Views/Home/Index.cshtml"));
            }

            var meeting = await _context.Meetings
                          .Include(m => m.TrainType)
                          .Include(m => m.Trainer)
                          .FirstOrDefaultAsync(m => m.MeetID == id);

            if (meeting == null)
            {
                ViewData["NotFound"] = "The requested meeting is no longer available";
                return(View("~/Views/Home/Index.cshtml"));
            }

            if (User.IsInRole("Trainer") && _userManager.GetUserId(User) != meeting.TrainerID)
            {
                ViewData["AccessDenied"] = true;
            }


            try
            {
                MeetingPrediction prediction            = _clusterer.Predict(meeting);
                List <Meeting>    MeetingsInSameCluster = await GetMeetingsInCluster(prediction.PredictedClusterId);

                MeetingsInSameCluster.Remove(meeting);
                ViewBag.otherMeetings = MeetingsInSameCluster;
            }
            catch
            {
                Console.Write("failed to cluster");
            }
            await getMeetingCoordinates(meeting.Trainer.Address, meeting.Trainer.City);

            return(View(meeting));
        }