Beispiel #1
0
        public ActionResult Index()
        {
            var userId = GetCurrentUser().Id;
            ReportFormViewModel reportFormView = _reportManagmentService.CreateFormViewModel(userId);

            return(View(reportFormView));
        }
Beispiel #2
0
        public ReportFormViewModel CreateFormViewModel(int userId)
        {
            var viewModel = new ReportFormViewModel
            {
                Managers = _personManagementService.GetActiveSupervisors()
            };
            var reports = new Dictionary <string, string>
            {
                { "1", "Employee Time Report" },
                { "2", "SDE Incidents/Service Requests and WO Report" },
                { "3", "Application Call List Report" }
            };

            viewModel.ReportTypes = reports;
            var dbDates = _sdeWorkOrderRepository.GetIncidentDates();

            var sdeDates = dbDates.Select(dbDate => dbDate.WorkOrderDate).ToList();

            viewModel.SdeReportDates = sdeDates;
            viewModel.ReportParams   = new ReportParameters {
                StartDate = Dates.GetPreviousSaturday(DateTime.Today).AddDays(-6), EndDate = Dates.GetPreviousSaturday(DateTime.Today), ManagerId = userId
            };

            return(viewModel);
        }
        public ActionResult Save(ReportFormViewModel reportFormViewModel)
        {
            if (reportFormViewModel.Report.ReportId == 0)
            {
                reportFormViewModel.Report.Members = _context.Members
                                                     .Where(m => reportFormViewModel.SelectedMembers.Contains(m.MemberId)).ToList();
                _context.Reports.Add(reportFormViewModel.Report);
            }
            else
            {
                var reportInDb = _context.Reports.Single(e => e.ReportId == reportFormViewModel.Report.ReportId);
                reportInDb.Name       = reportFormViewModel.Report.Name;
                reportInDb.ReportDate = reportFormViewModel.Report.ReportDate;
                reportInDb.Abstract   = reportFormViewModel.Report.Abstract;
                reportInDb.ReportText = reportFormViewModel.Report.ReportText;

                var updatedReportMembers = _context.Members
                                           .Where(m => reportFormViewModel.SelectedMembers.Contains(m.MemberId)).ToList();
                reportInDb.Members
                .Clear();     // Might be a more efficient way to do this but manually comparing causes a DataReader exception
                reportInDb.Members = updatedReportMembers;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Reports"));
        }
        public ActionResult CreateReport()
        {
            var viewModel = new ReportFormViewModel()
            {
                Categories = _categoryService.GetAll().AsEnumerable()
            };

            return(View("ReportForm", viewModel));
        }
        public ActionResult New()
        {
            var viewModel = new ReportFormViewModel
            {
                Members  = _context.Members.ToList(),
                Report   = new Report(),
                Subjects = _context.Subjects.ToList()
            };

            return(View("ReportForm", viewModel));
        }
        public ActionResult BugSubmission()
        {
            var browsers         = _context.Browsers.ToList();
            var operatingSystems = _context.OperatingSystems.ToList();

            var viewModel = new ReportFormViewModel
            {
                Browsers         = browsers,
                OperatingSystems = operatingSystems
            };

            return(View(viewModel));
        }
        public ViewResult New()
        {
            var members = _context.Members.ToList();

            var viewModel = new ReportFormViewModel
            {
                AllMembers = members.Select(m => new SelectListItem
                {
                    Text  = m.Name,
                    Value = m.MemberId.ToString()
                })
            };

            return(View("ReportForm", viewModel));
        }
Beispiel #8
0
        public ReportFormViewModel CreateReportViewModel(int id)
        {
            var normItems = _context.NormItems
                            .Where(x => x.NormId == id && x.ParentId == null)
                            .OrderBy(x => x.Order)
                            .ToList();

            var reportViewModel = new ReportFormViewModel
            {
                NormId        = id,
                Organisations = _context.Organisations.ToList(),
                ReportValues  = CreateInitialReportValuesList(normItems)
            };

            return(reportViewModel);
        }
        public ActionResult Edit(int id)
        {
            var report = _context.Reports.SingleOrDefault(e => e.Id == id);

            if (report == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ReportFormViewModel
            {
                Report   = report,
                Members  = _context.Members.ToList(),
                Subjects = _context.Subjects.ToList()
            };

            return(View("ReportForm", viewModel));
        }
        public ActionResult Save(BugReport bugReport)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ReportFormViewModel
                {
                    BugReport        = bugReport,
                    Browsers         = _context.Browsers.ToList(),
                    OperatingSystems = _context.OperatingSystems.ToList()
                };
                return(View("BugSubmission", viewModel));
            }
            else
            {
                _context.BugReport.Add(bugReport);
                _context.SaveChanges();

                return(RedirectToAction("SubmissionSuccess", "Home"));
            }
        }
        public ActionResult Edit(int id)
        {
            var report  = _context.Reports.SingleOrDefault(r => r.ReportId == id);
            var members = _context.Members.ToList();

            if (report == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ReportFormViewModel()
            {
                Report     = report,
                AllMembers = members.Select(m => new SelectListItem
                {
                    Text  = m.Name,
                    Value = m.MemberId.ToString()
                })
            };

            return(View("ReportForm", viewModel));
        }
        public ActionResult Save(Report report)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ReportFormViewModel
                {
                    Report   = report,
                    Members  = _context.Members.ToList(),
                    Subjects = _context.Subjects.ToList()
                };
                return(View("ReportForm", viewModel));
            }

            if (report.ReportFile.ContentLength > 0)
            {
                var    fileName = Path.GetFileName(report.ReportFile.FileName);
                string filePath = Path.Combine(Server.MapPath("~/App_Data/Uploads"), fileName);
                report.ReportFile.SaveAs(filePath);
            }

            if (report.Id == 0)
            {
                _context.Reports.Add(report);
            }

            else
            {
                var reportInDb = _context.Reports.Single(e => e.Id == report.Id);

                reportInDb.Name       = report.Name;
                reportInDb.MemberId   = report.MemberId;
                reportInDb.SubjectId  = report.SubjectId;
                reportInDb.Date       = report.Date;
                reportInDb.ReportFile = report.ReportFile;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Report"));
        }