// 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()); }
// GET: Settings public ActionResult Mediators() { //int user_id = 2; user user = (user)Session[ECGlobalConstants.CurrentUserMarcker]; if (user == null || user.id == 0) { return(RedirectToAction("Index", "Account")); } int user_id = user.id; UserModel um = new UserModel(user_id); int company_id = um._user.company_id; CompanyModel cm = new CompanyModel(company_id); ViewBag.page_subtitle = GlobalRes.Settings; #region EC-CC Viewbag ViewBag.is_cc = is_cc; string cc_ext = ""; if (is_cc) { cc_ext = "_cc"; } ViewBag.cc_extension = cc_ext; #endregion ViewBag.user_id = user_id; ViewBag.um = um; ViewBag.cm = cm; List <user> all_users = cm.AllMediators(cm._company.id, false, null); List <string> _company_user_emails = new List <string>(); _company_user_emails = (db.user.Where(t => ((t.company_id == company_id) && (t.role_id != ECLevelConstants.level_informant))).Select(t => t.email.Trim().ToLower())).ToList(); List <int> _company_user_ids = new List <int>(); _company_user_ids = (db.user.Where(t => ((t.company_id == company_id) && (t.role_id != ECLevelConstants.level_informant))).Select(t => t.id)).ToList(); List <invitation> company_invitations = db.invitation.Where(t => ((!_company_user_emails.Contains(t.email.ToLower().Trim()) && (t.used_flag == 0) && (_company_user_ids.Contains(t.sent_by_user_id))))).ToList(); foreach (invitation _inv in company_invitations) { user _user = new user(); _user.id = 0; _user.role_id = 0; _user.first_nm = _inv.email; _user.email = _inv.email; _user.last_nm = ""; _user.location_nm = ""; _user.photo_path = ""; _user.title_ds = ""; _user.notepad_tx = App_LocalResources.GlobalRes.Awaiting_registration; all_users.Add(_user); } ViewBag.AllUser = all_users; return(View()); }
public object Get() { user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker]; if (user == null || user.id == 0) { return(null); } UserModel um = new UserModel(user.id); //var departments = DB.company_case_admin_department.Where(x => x.company_id == user.company_id && x.status_id == 2).ToList(); var departments = DB.company_department .AsNoTracking() .Where(x => x.company_id == user.company_id && x.status_id == 2) .ToList(); var users = DB.user .AsNoTracking() .Where(x => x.company_id == user.company_id && x.status_id == 2 && x.role_id == 6) .ToList(); var scopes = DB.scope .AsNoTracking() .ToList(); var items = DB.company_case_routing .AsNoTracking() .Where(x => x.company_id == user.company_id) .ToList(); var types = DB.company_secondary_type .AsNoTracking() .Where(x => x.company_id == user.company_id && x.status_id == 2) .ToList(); var ids = items .Select(x => x.id) .ToList(); var files = DB.company_case_routing_attachments .AsNoTracking() .Where(x => ids.Contains(x.company_case_routing_id) & x.status_id == 2) .ToList(); types.ForEach(x => { var item = items.FirstOrDefault(z => z.company_secondary_type_id == x.id); if (item == null) { items.Add(new company_case_routing { id = 0, client_id = 1, status_id = 2, company_secondary_type_id = x.id, company_case_admin_department_id = 0, user_id = 0, scope_id = 0, }); } }); var locations = DB.company_location .AsNoTracking() .Where(x => x.company_id == user.company_id && x.status_id == 2) .OrderBy(x => x.location_en) .ToList(); ids = locations.Select(x => x.id).ToList(); var locationItems = DB.company_case_routing_location .AsNoTracking() .Where(x => ids.Contains(x.company_location_id) & x.company_id == user.company_id) .ToList(); locations.ForEach(x => { var item = locationItems.FirstOrDefault(z => z.company_location_id == x.id); if (item == null) { locationItems.Add(new company_case_routing_location { id = 0, client_id = 1, status_id = 2, company_location_id = x.id, user_id = 0, scope_id = 0, company_id = user.company_id, }); } }); var cm = new CompanyModel(user.company_id); var m = new { types = types, departments = departments, users = cm.AllMediators(user.company_id, true, null).Select(x => new { id = x.id, first_nm = x.first_nm, last_nm = x.last_nm, }), scopes = scopes, items = items, files = files, locations = locations, locationItems = locationItems, }; return(ResponseObject2Json(m)); }