Esempio n. 1
0
        public async Task <ActionResult> PlaceDetail(int id)
        {
            VotePlaceModel place = _votePlaceModelService.GetVotePlaceModel(id);
            //if (place == null)
            //{
            //    return RedirectToAction("Error", "Vote", new { text = $"There is no any place with id = {id}" });
            //}
            var evidences_raw = (from E in _compromisingEvidenceModelService.GetCompromisingEvidenceModels()
                                 where E.VotePlaceId.Id == id
                                 select E).Include("UserId");
            List <CompromisingEvidenceModel> evidences_pre = evidences_raw.ToList();

            List <EvidenceEntity> evidences = new List <EvidenceEntity>();
            // TODO: Try to optimize image loading
            uint index = 0;

            foreach (var ev in evidences_pre)
            {
                //ev.UserId = await _userManager.GetUserAsync(HttpContext.User);
                index++;
                evidences.Add(
                    new EvidenceEntity()
                {
                    Evidence = ev,
                    Files    = await(
                        from F in _compromisingEvidenceFileModelService.GetCompromisingEvidenceFileModels()
                        where F.CompromisingEvidenceId.Id == ev.Id
                        select F
                        ).ToListAsync(),
                    Email = ev.UserId?.Email,
                    index = index
                });
            }

            var TotalVotes = (from V in _voteModelService.GetVoteModels()
                              where V.VotePlaceId.Id == id
                              select V.TargetId).Count();

            ViewBag.TotalVotes     = TotalVotes;
            ViewBag.TotalEvidences = evidences.Count();
            ViewBag.Region         = place.Region;
            ViewBag.Town           = place.Town;
            ViewBag.Street         = place.Street;
            ViewBag.House          = place.House;
            ViewBag.Id             = place.Id;

            ViewBag.evidences = evidences;

            ViewBag.isAuthenticated = HttpContext.User.Identity.IsAuthenticated;

            var evidenceForm = new EvidenceForm()
            {
                PlaceId = place.Id
            };

            return(View(evidenceForm));
        }
Esempio n. 2
0
        public async Task <ActionResult> UserDetail(string id)
        {
            var user = await _userManager.FindByIdAsync(id);

            var evidences_raw = (from E in _compromisingEvidenceModelService.GetCompromisingEvidenceModels()
                                 where E.UserId.Id == id
                                 select E).Include("UserId").Include("VotePlaceId");
            List <CompromisingEvidenceModel> evidences_pre = evidences_raw.ToList();
            List <EvidenceEntity>            evidences     = new List <EvidenceEntity>();
            uint index = 0;

            foreach (var ev in evidences_pre)
            {
                index++;
                evidences.Add(
                    new EvidenceEntity()
                {
                    Evidence = ev,
                    Files    = await(
                        from F in _compromisingEvidenceFileModelService.GetCompromisingEvidenceFileModels()
                        where F.CompromisingEvidenceId.Id == ev.Id
                        select F
                        ).ToListAsync(),
                    index = index
                });
            }
            List <NotificationModel> notifications = await _notificationModelService.GetNotificationModels().Where(model => model.ApplicationGetterId.Id == user.Id).ToListAsync();

            UserForm userForm = new UserForm()
            {
                User          = user,
                Evidences     = evidences,
                Notifications = notifications
            };

            return(View(userForm));
        }