Example #1
0
        public IHttpResponse Details(int id)
        {
            var report = this.db.Reports.FirstOrDefault(r => r.Id == id);

            if (report == null)
            {
                return(this.BadRequestError("Invalid report id!"));
            }

            var reportDetailsViewModel = new ReportDetailsViewModel
            {
                Id              = report.Id,
                Task            = report.Task.Title,
                Level           = report.Task.AffectedSectors.Count,
                Status          = report.Status.ToString(),
                DueDate         = report.Task.DueDate.ToShortDateString(),
                ReportedOn      = report.ReportedOn.ToShortDateString(),
                Reporter        = report.Reporter.Username,
                Participants    = report.Task.Participants,
                AffectedSectors = string.Join(", ", report.Task.AffectedSectors.Select(s => s.Sector.ToString())),
                TaskDescription = report.Task.Description
            };

            return(this.View(reportDetailsViewModel));
        }
Example #2
0
        public ActionResult Download(ReportDetailsViewModel model)
        {
            IEnumerable <int> quoteIds = model.Quotes.Select(x => x.Id);
            List <Quote>      quotes   = IncludeAllNavigationProperties(db.Quotes).Where(q => quoteIds.Contains(q.Id)).ToList();

            return(File(Encoding.ASCII.GetBytes(GenerateReportString(quotes, model.Columns)), "text/plain", $"Report_{DateTime.Now}.csv"));
        }
Example #3
0
        public async Task <IActionResult> Details(int id)
        {
            try
            {
                ReportDetailsViewModel model = new ReportDetailsViewModel();
                var report = _reportRepository.GetReportById(id);
                var user   = await _userManager.GetUserAsync(User);

                model.Report = report;
                // Get number of upvotes
                model.NumberOfUpvotes = _upvoteRepository.GetUpVoteByReportId(report).Count();

                if (_upvoteRepository.UpvoteExists(report, user) != null)
                {
                    model.IsLiked = true;
                }
                else
                {
                    model.IsLiked = false;
                }

                return(View(model));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(View("Error"));
            }
        }
        public IHttpResponse Details(int id)
        {
            var report = Db.Reports.Include(x => x.Task)
                         .Include(x => x.Reporter)
                         .Include(x => x.Task.AffectedSectors)
                         .FirstOrDefault(x => x.Id == id);

            var affectedSectors = Db.TaskSectors.Where(x => x.TaskId == report.TaskId)
                                  .Select(x => x.Sector.Name).ToList();

            var reportModed = new ReportDetailsViewModel
            {
                ReportId             = report.Id,
                Reporter             = report.Reporter.Username,
                Description          = report.Task.Description,
                Title                = report.Task.Title,
                Status               = report.Status.ToString(),
                Participants         = report.Task.Participants,
                ReportedOn           = report.ReportedOn.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture),
                DueDate              = report.Task.DueDate?.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture),
                AffectedSectors      = string.Join(", ", affectedSectors),
                AffectedSectorsCount = affectedSectors.Count
            };

            return(this.View(reportModed));
        }
        public ReportDetailsViewModel GetReportById(int id)
        {
            var reportViewModel = new ReportDetailsViewModel();

            var report = this.context
                         .Reports
                         .FirstOrDefault(r => r.Id == id);

            var task = this.taskService
                       .GetTaskById(report.TaskId);

            reportViewModel.Id         = report.Id;
            reportViewModel.TaskName   = task.Title;
            reportViewModel.TaskLevel  = task.Level;
            reportViewModel.Status     = report.Status.ToString();
            reportViewModel.DueDate    = task.DueDate;
            reportViewModel.ReportedOn = report.ReportedOn.ToString("dd/MM/yyyy");

            reportViewModel.ReporterName = this.context
                                           .Users
                                           .FirstOrDefault(u => u.Id == report.ReporterId)
                                           ?.Username;

            reportViewModel.Participants    = task.Participants;
            reportViewModel.AffectedSectors = task.AffectedSectors;
            reportViewModel.TaskDescription = task.Description;

            return(reportViewModel);
        }
Example #6
0
        public IActionResult Details(int taskId)
        {
            if (!this.IsAuthenticated())
            {
                return(RedirectToAction("/users/login"));
            }

            if (!this.IsAdmin())
            {
                return(RedirectToAction("/users/login"));
            }

            Report report = this.reportService.FindReport(taskId);
            User   user   = this.userService.FindUserById(report.UserId);
            Task   task   = this.taskService.FindTask(report.TaskId);


            var reportDetailsViewModel = new ReportDetailsViewModel
            {
                Id              = task.Id,
                Title           = task.Title,
                Description     = task.Description,
                AffectedSectors = string.Join(",", task.AffectedSectors.Select(x => x.Sector)),
                DueDate         = task.DueDate.ToShortDateString(),
                Level           = task.AffectedSectors.Count,
                Participants    = task.Participants,
                Reporter        = user.Username,
                ReportedOn      = report.ReportedOn.ToShortTimeString(),
                Status          = report.Status.ToString("g")
            };

            this.Model.Data["ReportDetailsViewModel"] = reportDetailsViewModel;

            return(this.View());
        }
        public IHttpResponse Details(int id)
        {
            var report = this.DbContext.Reports.FirstOrDefault(r => r.Id == id);

            if (report == null)
            {
                return(this.BadRequestErrorWithView($"Report with id {id} not found."));
            }

            var viewModel = new ReportDetailsViewModel()
            {
                Id              = report.Id,
                TaskTitle       = report.Task.Title,
                TaskLevel       = report.Task.Sectors.Count(),
                Status          = report.Status,
                ReportedOn      = report.ReportedOn.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
                Participants    = report.Task.Participants,
                AffectedSectors = string.Join(", ", report.Task.Sectors.Select(s => s.Sector)),
                Reporter        = report.Reporter.Username,
                TaskDescription = report.Task.Description,
            };

            if (report.Task.DueDate != null)
            {
                viewModel.DueDate = report.Task.DueDate.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            }

            return(this.View(viewName: "ReportDetails", model: viewModel));
        }
Example #8
0
        public IHttpResponse Details(int Id)
        {
            if (!this.DbContext.Reports.Any(r => r.Id == Id))
            {
                return(this.BadRequestError("Report doesn't exist!"));
            }
            else if (this.User.Role != "Admin")
            {
                return(this.BadRequestError("404 Page Not Found"));
            }

            ReportDetailsViewModel viewModel =
                this.DbContext
                .Reports
                .Select(r => new ReportDetailsViewModel
            {
                Id                  = r.Id,
                TaskTitle           = r.Task.Title,
                TaskDescription     = r.Task.Description,
                TaskLevel           = r.Task.AffectedSectors.Count,
                TaskAffectedSectors = string.Join(", ", r.Task.AffectedSectors.Select(a => a.Sector.SectorType.ToString())),
                TaskParticipants    = string.Join(", ", r.Task.Participants.Select(p => p.Participant.Name)),
                TaskDueDate         = r.Task.DueDate.ToString("d"),
                ReportedOn          = r.ReportedOn.ToString("d"),
                ReporterName        = r.Reporter.Username,
                ReportStatus        = r.Status.ToString()
            })
                .Where(r => r.Id == Id)
                .First();

            return(this.View(viewModel));
        }
        public ActionResult ReportDetails(string id, string eventid)
        {
            ReportDetailsViewModel report = new ReportDetailsViewModel();
            var t = report.GetReportDetails(id, eventid);

            t.Wait();

            return(View(report));
        }
Example #10
0
        public IHttpResponse Details(int id)
        {
            var report = this.db
                         .Reports
                         .FirstOrDefault(x => x.Id == id);

            if (report == null)
            {
                this.BadRequestError($"Report with Id: {id} was not found!");
            }

            var user = this.db
                       .Users
                       .FirstOrDefault(x => x.Id == report.ReporterId);

            if (report == null)
            {
                this.BadRequestError($"Reporter with Id: {user.Id} was not found!");
            }

            var model = new ReportDetailsViewModel
            {
                Id           = report.Id,
                Description  = report.Task.Description,
                DueDate      = report.Task.DueDate == null?"No date": report.Task.DueDate.Value.ToString("dd/MM/yyyy"),
                Level        = report.Task.AffectedSectors.Count(),
                Participants = report.Task.Participants,
                ReportedBy   = user.Username,
                ReportedDate = report.ReportedOn.ToString("dd/MM/yyyy"),
                TaskTitle    = report.Task.Title,
                Status       = report.Status.ToString()
            };
            var affectedSectors = "None";

            if (report.Task.AffectedSectors.Count > 0)
            {
                affectedSectors = string.Join(", ", report.Task.AffectedSectors.Select(x => x.Sector.ToString()));
            }

            model.AffectedSectors = affectedSectors;

            return(this.View(model));
        }
Example #11
0
        public IHttpResponse Details(int id)
        {
            if (this.User.IsLoggedIn && this.User.Role == "Admin")
            {
                var report = this.Db.Reports.FirstOrDefault(x => x.Id == id);

                if (report == null)
                {
                    return(this.BadRequestError("Invalid Report Id!"));
                }

                var participants = new List <string>();
                foreach (var p in report.Task.Participants)
                {
                    participants.Add(p.User.Username);
                }

                var sectors = new List <string>();
                foreach (var s in report.Task.AffectedSectors)
                {
                    sectors.Add(s.Sector.ToString());
                }

                var viewModel = new ReportDetailsViewModel
                {
                    Id              = id,
                    Level           = report.Task.AffectedSectors.Count,
                    Description     = report.Task.Description,
                    DueDate         = report.Task.DueDate.Value.ToString("dd/MM/yyyy"),
                    ReportedOn      = report.ReportedOn.ToString("dd/MM/yyy"),
                    Title           = report.Task.Title,
                    Reporter        = report.Reporter.Username,
                    Status          = report.Status.ToString(),
                    AffectedSectors = string.Join(", ", sectors),
                    Participants    = string.Join(", ", participants)
                };

                return(this.View(viewModel));
            }

            return(this.Redirect("/"));
        }
        public IHttpResponse Details(int id)
        {
            if (this.User.Role != Role.Admin.ToString())
            {
                return(this.BadRequestError("You do not have permission to access this functionality!"));
            }

            var report = this.ReportService.GetReportById(id);

            if (report == null)
            {
                return(this.BadRequestError("Invalid report id"));
            }

            var affectedSectorsAsString = new List <string>();

            foreach (var taskAffectedSector in report.Task.AffectedSectors)
            {
                var sector = taskAffectedSector.Sector.ToString();
                affectedSectorsAsString.Add(sector);
            }

            var reportAsViewModel = new ReportDetailsViewModel()
            {
                Id = report.Id,
                TaskAffectedSectors = string.Join(", ", affectedSectorsAsString),
                TaskDescription     = report.Task.Description,
                TaskDueDate         = report.Task.DueDate.ToString(),
                TaskTitle           = report.Task.Title,
                TaskLevel           = report.Task.AffectedSectors.Count(),
                TaskParticipants    = report.Task.Participants,
                Status     = report.Status.ToString(),
                ReportedOn = report.ReportedOn.ToString(),
                Username   = report.Reporter.Username,
                UserRole   = this.User.Role
            };


            return(this.View(reportAsViewModel));
        }
        public IActionResult Details(int reportId)
        {
            var report = this.DbContext.Reports.FirstOrDefault(r => r.Id == reportId);

            var details = new ReportDetailsViewModel()
            {
                ReportId        = report.Id,
                TaskTitle       = report.Task.Title,
                TaskLevel       = report.Task.Level,
                TaskDescription = report.Task.Description,
                Status          = report.Status.ToString(),
                Reporter        = report.Reporter.Username,
                ReportedOn      = report.ReportedOn.ToString(CultureInfo.InvariantCulture),
                DueDate         = report.Task.DueDate.ToString(CultureInfo.InvariantCulture),
                Participants    = string.Join(',', report.Task.Participants.Select(p => p.User.Username)),
                AffectedSectors = string.Join(',', report.Task.AffectedSectors.Select(s => s.Sector.ToString()))
            };

            this.Model.Data["Details"] = details;

            return(this.View());
        }
        public IActionResult Details(int Id)
        {
            var report = this.reportsService.GetReportById(Id);

            var reportDetailsViewModel = new ReportDetailsViewModel
            {
                TaskTitle       = report.Task.Title,
                Id              = report.Id,
                Description     = report.Task.Description,
                DueDate         = report.Task.DueDate.ToShortDateString(),
                ReportedOn      = report.ReportedOn.ToShortDateString(),
                Reporter        = report.Reporter.Username,
                Level           = report.Task.AffectedSectors.Count,
                Participants    = report.Task.Participants,
                Status          = report.Status.ToString(),
                AffectedSectors = string.Join(" ", report.Task.AffectedSectors.Select(asf => asf.Sector))
            };

            this.Model.Data["ReportDetails"] = reportDetailsViewModel;

            return(this.View());
        }
        public IActionResult Details(int id)
        {
            var report = this.reportService.GetById(id);

            var reportViewModel = new ReportDetailsViewModel
            {
                Id              = report.Id,
                Task            = report.Task.Title,
                Level           = report.Task.AffectedSectors.Count,
                Status          = report.Status.ToString(),
                DueDate         = report.Task.DueDate?.ToShortDateString(),
                AffectedSectors = string.Join(", ", report.Task.AffectedSectors.Select(s => s.Sector)),
                Participants    = report.Task.Participants,
                ReportedOn      = report.ReportedOn.ToShortDateString(),
                Reporter        = report.Reporter.Username,
                Description     = report.Task.Description
            };

            this.Model.Data["ReportDetails"] = reportViewModel;

            return(this.View());
        }
Example #16
0
        public IActionResult Details(int id)
        {
            var report = this.ReportService.GetReportById(id);

            if (report == null)
            {
                this.Model.Data["Error"] = "There is no report with that id";
                return(this.RedirectToAction("/"));
            }

            var affectedSectorsAsString = new List <string>();

            foreach (var taskAffectedSector in report.Task.AffectedSectors)
            {
                var sector = taskAffectedSector.Sector.ToString();
                affectedSectorsAsString.Add(sector);
            }

            var reportAsViewModel = new ReportDetailsViewModel()
            {
                Id = report.Id,
                TaskAffectedSectors = string.Join(", ", affectedSectorsAsString),
                TaskDescription     = report.Task.Description,
                TaskDueDate         = report.Task.DueDate.ToString(),
                TaskTitle           = report.Task.Title,
                TaskLevel           = report.Task.AffectedSectors.Count(),
                TaskParticipants    = report.Task.Participants,
                Status     = report.Status.ToString(),
                ReportedOn = report.ReportedOn.ToString(),
                Username   = report.Reporter.Username
            };

            this.Model.Data["TaskInfo"] = reportAsViewModel;

            return(this.View());
        }
        public IActionResult Details(string id)
        {
            ReportDetailsViewModel report = reportsService.GetById(id);

            return(View(report));
        }
Example #18
0
        public ActionResult Details(string id)
        {
            ReportListDetailsViewModel reportListDetailsViewModel = new ReportListDetailsViewModel();
            ReportBusinessLayer        empBal      = new ReportBusinessLayer();
            List <LogRecord>           recordsords = empBal.GetRecords();

            reportListDetailsViewModel.Start = DateTime.Parse(GlobalVariables.Start).ToString("d");
            reportListDetailsViewModel.End   = DateTime.Parse(GlobalVariables.End).ToString("d");

            List <ReportDetailsViewModel> reportViewModels = new List <ReportDetailsViewModel>();
            List <Employee> employees = new List <Employee>();

            employees = empBal.GetEmployees();
            employees = employees.Where(a => GlobalVariables.L1List.Contains(a.L1)).ToList();
            employees = employees.Where(a => GlobalVariables.L2List.Contains(a.L2)).ToList();
            employees = employees.Where(a => GlobalVariables.L3List.Contains(a.L3)).ToList();
            employees = employees.Where(a => GlobalVariables.L4List.Contains(a.L4)).ToList();
            employees = employees.Where(a => GlobalVariables.L5List.Contains(a.L5)).ToList();
            employees = employees.Where(a => GlobalVariables.RegionList.Contains(a.AreaCode)).ToList();
            employees = employees.Where(a => GlobalVariables.CountryList.Contains(a.Country)).ToList();


            employees = employees.Where(a => GlobalVariables.StatusList.Contains(a.Status)).ToList();

            reportListDetailsViewModel.TotalCount = recordsords.Count();
            var em = from m in recordsords
                     where m.Event1.Equals(id) && GlobalVariables.Start.CompareTo(DateTime.Parse(m.DateInclude).ToString("o").Substring(0, 10)) <= 0 && GlobalVariables.End.CompareTo(DateTime.Parse(m.DateInclude).ToString("o").Substring(0, 10)) >= 0
                     select m.Email.ToLower();


            var empDetail = from m in em
                            join empl in employees on m equals empl.Email.ToLower()
                            group empl by empl.Email into grp
                            select new { Email = grp.Key.ToLower(), Cnt = grp.Count(), Code = grp.First().AreaCode, Cty = grp.First().Country };

            reportListDetailsViewModel.CurCount = em.Distinct().Count();
            foreach (var detail in empDetail)
            {
                ReportDetailsViewModel reportViewModel = new ReportDetailsViewModel();
                //reportViewModel.Id = detail.Id;
                reportViewModel.Email    = detail.Email;
                reportViewModel.Country  = detail.Cty;
                reportViewModel.AreaCode = detail.Code;
                reportViewModel.Count    = detail.Cnt;

                reportViewModels.Add(reportViewModel);
            }
            reportListDetailsViewModel.Event1  = id;
            reportListDetailsViewModel.Records = reportViewModels;

            reportListDetailsViewModel.L1List      = GlobalVariables.Base.L1List;
            reportListDetailsViewModel.L2List      = GlobalVariables.Base.L2List;
            reportListDetailsViewModel.L3List      = GlobalVariables.Base.L3List;
            reportListDetailsViewModel.L4List      = GlobalVariables.Base.L4List;
            reportListDetailsViewModel.L5List      = GlobalVariables.Base.L5List;
            reportListDetailsViewModel.CountryList = GlobalVariables.Base.CountryList;
            reportListDetailsViewModel.RegionList  = GlobalVariables.Base.RegionList;
            reportListDetailsViewModel.StatusList  = GlobalVariables.Base.StatusList;

            reportListDetailsViewModel.SelectedL1List      = GlobalVariables.L1List;
            reportListDetailsViewModel.SelectedL2List      = GlobalVariables.L2List;
            reportListDetailsViewModel.SelectedL3List      = GlobalVariables.L3List;
            reportListDetailsViewModel.SelectedL4List      = GlobalVariables.L4List;
            reportListDetailsViewModel.SelectedL5List      = GlobalVariables.L5List;
            reportListDetailsViewModel.SelectedCountryList = GlobalVariables.CountryList;
            reportListDetailsViewModel.SelectedRegionList  = GlobalVariables.RegionList;
            reportListDetailsViewModel.SelectedStatusList  = GlobalVariables.StatusList;

            return(View("Details", reportListDetailsViewModel));
        }