コード例 #1
0
        public async Task <IActionResult> NewReport([FromBody] NewReportModel model)
        {
            if (!this.IsTokenValid(_tokenService.GetTemporaryToken(this.GetCurrentUserId())))
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var command = _mapper.Map <NewReportCommand>(model);

            command.CurrentUserId = UserId;
            var newId = await _mediator.Send(command);

            return(Ok(newId));
        }
コード例 #2
0
        // GET: ReporterDashboard

        /* public ActionResultExtended Index(int? id)
         * {
         *   if (!id.HasValue)
         *       id = 166;
         *   NewReportModel reporterDashboard = new NewReportModel();
         *   ViewBag.user_id = id.Value; // 167-171
         * }*/
        public ActionResult Index(int?id)
        {
            int report_id = 0;

            if (!id.HasValue)
            {
                return(RedirectToAction("Index", "Account"));
            }
            else
            {
                report_id = id.Value;// 167-171??
            }
            user user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

            if (user == null || user.id == 0)
            {
                return(RedirectToAction("Index", "Account"));
            }

            int         user_id = user.id;
            ReportModel rm      = new ReportModel(report_id);

            if (!rm.HasAccessToReport(user_id))
            {
                return(RedirectToAction("Index", "Account"));
            }

            glb.UpdateReportRead(user_id, report_id);
            NewReportModel reporterDashboard = new NewReportModel();


            if ((rm._investigation_status != 1) && (rm._investigation_status != 2) && (rm._investigation_status != 7))
            {
                // case is not approved to work on it yet, need to approve first. if == 7 - its spam, so they will share the view.
                return(RedirectToAction("Index", "NewCase", new { report_id = id }));
            }

            #region EC-CC Viewbag
            ViewBag.is_cc = is_cc;
            string cc_ext = "";
            if (is_cc)
            {
                cc_ext = "_cc";
            }
            ViewBag.cc_extension = cc_ext;
            #endregion


            UserModel um = new UserModel(user_id);

            Dictionary <int, string> month = m_DateTimeHelper.ShortMonth();

            ViewBag.user_id = user_id;
            ViewBag.um      = um;

            ViewBag.attachmentFiles         = getAttachmentFiles(id.Value);
            ViewBag.getNonMediatorsInvolved = getNonMediatorsInvolved(id.Value);
            ViewBag.AllScopes      = db.scope.OrderBy(x => x.scope_en).ToList();
            ViewBag.AllSeverities  = db.severity.OrderBy(x => x.id).ToList();
            ViewBag.AllDepartments = db.company_department.Where(x => x.company_id == um._user.company_id && x.status_id == 2).OrderBy(x => x.department_en).ToList();
            ViewBag.AllIncidets    = db.company_secondary_type.Where(x => x.company_id == um._user.company_id && x.status_id == 2).OrderBy(x => x.secondary_type_en).ToList();
            CompanyModel     cm = new CompanyModel(um._user.company_id);
            List <user>      available_users = cm.AllMediators(um._user.company_id, true, null).OrderBy(x => x.first_nm).ToList();
            List <UserItems> _users          = new List <UserItems>();

            foreach (user _user in available_users)
            {
                UserItems _new_user = new UserItems();
                _new_user.FirstName = _user.first_nm;
                _new_user.LastName  = _user.last_nm;
                _new_user.Id        = _user.id;
                _users.Add(_new_user);
            }

            ViewBag.AllOwners = _users;

            bool has_access = rm.HasAccessToReport(user_id);

            if ((!has_access) || (user.role_id == 8))
            {
                return(RedirectToAction("Index", "Account"));
            }
            else
            {
                ViewBag.report_id = report_id;
            }


            if ((rm._investigation_status == 1) && (user.role_id == 4 || user.role_id == 5 || user.role_id == 6 || user.role_id == 7))
            {
                if (!db.report_log.Any(item => ((item.action_id == 28) && (item.report_id == report_id) && (item.string_to_add == App_LocalResources.GlobalRes._Completed))))
                {
                    // need to update investigation status from pending to review after first mediator accessed the report
                    report_investigation_status _review_status = new report_investigation_status();
                    _review_status.created_date            = DateTime.Now;
                    _review_status.investigation_status_id = 2;
                    _review_status.report_id = report_id;
                    _review_status.user_id   = user_id;
                    db.report_investigation_status.Add(_review_status);
                    glb.UpdateReportLog(user_id, 28, report_id, App_LocalResources.GlobalRes._Completed, null, "");
                    glb.UpdateReportLog(user_id, 20, report_id, App_LocalResources.GlobalRes._Started, null, "");
                }
            }


            /*
             * report report = new report();
             * report = reporterDashboard.getReport(175);
             *
             *
             * ViewBag.id = report.id;
             *
             * ViewBag.generatedName = report.report_name_generic;
             * ViewBag.companyName = report.submitted_company_nm;
             *
             * ViewBag.reported = report.reported_dt.Day + " " + month[report.reported_dt.Month] + " " + report.reported_dt.Year;
             * ViewBag.totalTime = (System.DateTime.Now - report.reported_dt).Days + " days";
             *
             * ViewBag.happenedIn = report.other_location_name;
             *
             *
             * //Parties involved
             * if (report.management_know_id == null)
             * {
             *  ViewBag.managmentKnow = "NULL";
             * }
             * else
             * {
             *  ViewBag.managmentKnow = reporterDashboard.getManagmentKnowInfo((Int16)report.management_know_id);
             * }
             *
             *
             * report_secondary_type reportSecondaryType = new report_secondary_type();
             * reportSecondaryType = reporterDashboard.getReportSecondaryType(report.id);
             *
             * //Case nformation
             * ViewBag.reportingAbout = reportSecondaryType.secondary_type_nm;
             * ViewBag.incidentHappend = report.incident_dt.Day + " " + month[report.incident_dt.Month] + " " + report.incident_dt.Year;
             * ViewBag.incidentDescription = report.description;
             *
             * //Messages
             * ViewBag.messages = reporterDashboard.getMessagesList(report.id);
             */

            ViewBag.company_location         = db.company_location.Where(x => x.company_id == rm._report.company_id).ToList();
            ViewBag.report_mediator_assigned = db.report_mediator_assigned.Where(x => x.report_id == report_id).ToList();
            ViewBag.report_mediator_involved = db.report_mediator_involved.Where(x => x.report_id == report_id).ToList();
            var report_secondary_type = db.report_secondary_type.Where(x => x.report_id == report_id).ToList();
            ViewBag.report_secondary_type = report_secondary_type;
            var ids = report_secondary_type.Select(x => x.secondary_type_id).ToList();
            var company_case_routing = db.company_case_routing.Where(x => x.company_id == rm._report.company_id & ids.Contains(x.company_secondary_type_id)).ToList();
            ViewBag.company_case_routing = company_case_routing;

            ids = company_case_routing.Select(x => x.id).ToList();
            ViewBag.AllPolicies = db.company_case_routing_attachments
                                  .Where(x => ids.Contains(x.company_case_routing_id) & x.status_id == 2)
                                  .OrderBy(x => x.company_case_routing_id)
                                  .ThenBy(x => x.file_nm)
                                  .ToList();

            var midiators_roles = new int[] { 4, 5, 6 };
            ViewBag.AllMediators = db.user
                                   .Where(x => x.company_id == rm._report.company_id & midiators_roles.Contains(x.role_id))
                                   .ToList();

            return(View());
        }