public object Get() { user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker]; if (user == null || user.id == 0) { return(null); } var posters = DB.poster.AsNoTracking().ToList(); var messages = DB.message_posters.AsNoTracking().ToList(); try { var m = new { posters = DB.poster .ToList() .Select(x => new { poster = x, message = messages.FirstOrDefault(z => z.id == x.poster_message_posters_id), posterCategoryNames = DB.poster_industry_posters.Where(z => z.poster_id == x.id).ToList() }) .ToList(), categories = DB.industry_posters.Where(x => x.status == 2).ToList(), messages = messages.Where(x => x.status == 2).ToList(), languages = new[] { new { Id = 1, Name = LocalizationGetter.GetString("English") }, }, avaibleFormats = new[] { new { Id = 1, Name = LocalizationGetter.GetString("AvailableFormat_1") }, new { Id = 2, Name = LocalizationGetter.GetString("AvailableFormat_2") }, new { Id = 3, Name = LocalizationGetter.GetString("AvailableFormat_3") }, }, }; return(ResponseObject2Json(m)); } catch (Exception exc) { return("EXC! " + exc.Message); } }
public object Get([FromUri] Filter filter) { user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker]; // DEBUG //user = DB.user.FirstOrDefault(x => x.id == 2); // DEBUG if (user == null || user.id == 0) { return(null); } UserModel um = new UserModel(user.id); var company_secondary_types = DB.company_secondary_type .Where(x => x.company_id == um._user.company_id) .OrderBy(x => x.secondary_type_en) .ToList(); var report_secondary_type_selected = DB.report_secondary_type .Where(x => x.report_id == filter.Report_id) .ToList(); var all_mediators = DB.user .Where(item => (item.company_id == user.company_id) && (item.role_id == 4 || item.role_id == 5)) .ToList(); var mediator_involved = DB.report_mediator_involved .Where(x => x.report_id == filter.Report_id & x.status_id == 2) .ToList(); var mediator_not_involved = DB.report_non_mediator_involved .Where(x => x.report_id == filter.Report_id) .ToList(); var mediator_assigned = DB.report_mediator_assigned .Where(x => x.report_id == filter.Report_id & x.status_id == 2) .ToList(); var departments = DB.company_department .Where(x => x.company_id == user.company_id) .OrderBy(x => x.department_en) .ToList(); var m = new { report_secondary_type_selected = company_secondary_types .Where(x => report_secondary_type_selected.Select(z => z.secondary_type_id).Contains(x.id)) .Select(x => new { id = x.id, secondary_type_en = x.secondary_type_en, added_by_reporter = report_secondary_type_selected.FirstOrDefault(z => z.secondary_type_id == x.id).added_by_reporter, }) .OrderByDescending(x => x.added_by_reporter) .ThenBy(x => x.secondary_type_en) .ToList(), report_secondary_type_selected_avilable = company_secondary_types .Where(x => !report_secondary_type_selected.Select(z => z.secondary_type_id).Contains(x.id) && x.status_id == 2) .ToList(), mediator_involved = all_mediators .Where(x => mediator_involved.Select(z => z.mediator_id).Contains(x.id)) .Select(x => new { id = x.id, first_nm = x.first_nm, last_nm = x.last_nm, added_by_reporter = mediator_involved.FirstOrDefault(z => z.mediator_id == x.id).added_by_reporter, }).ToList(), mediator_not_involved = mediator_not_involved, mediator_all = all_mediators .Where(x => !mediator_involved.Select(z => z.mediator_id).Contains(x.id) & !mediator_assigned.Select(z => z.mediator_id).Contains(x.id)) .Select(x => new { id = x.id, first_nm = x.first_nm, last_nm = x.last_nm }).ToList(), departments_all = departments, departments_report = DB.report_department .Where(x => x.report_id == filter.Report_id) .ToList() .Select(x => new { id = x.department_id, added_by_reporter = x.added_by_reporter, name = departments.FirstOrDefault(z => z.id == x.department_id)?.department_en, }) .OrderByDescending(x => x.added_by_reporter) .ThenBy(x => x.name) .ToList(), note1 = DB.report_inv_notes.FirstOrDefault(x => x.report_id == filter.Report_id & x.type == 1)?.note, note2 = DB.report_inv_notes.FirstOrDefault(x => x.report_id == filter.Report_id & x.type == 2)?.note, company_root_cases_behavioral = DB.company_root_cases_behavioral .Where(x => x.company_id == user.company_id & x.status_id == 2) .OrderBy(x => x.name_en) .ToList(), company_root_cases_external = DB.company_root_cases_external .Where(x => x.company_id == user.company_id & x.status_id == 2) .OrderBy(x => x.name_en) .ToList(), company_root_cases_organizational = DB.company_root_cases_organizational .Where(x => x.company_id == user.company_id & x.status_id == 2) .OrderBy(x => x.name_en) .ToList(), report_investigation_methodology = DB.report_investigation_methodology .Where(x => x.report_id == filter.Report_id) .ToList() .Where(x => report_secondary_type_selected.Select(z => z.secondary_type_id).ToList().Contains(x.report_secondary_type_id)) .ToList(), addNewPersonRoles = DB.role_in_report.OrderBy(x => x.role_en).ToList() }; m.addNewPersonRoles.Insert(0, new role_in_report { id = 0, role_en = LocalizationGetter.GetString("Other") }); return(ResponseObject2Json(m)); }
public object Post(Filter filter) { user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker]; if (user == null || user.id == 0) { return(null); } if (filter.AddToTeam.HasValue) { UserModel userModel = UserModel.inst; GlobalFunctions glb = new GlobalFunctions(); IEmailAddressHelper m_EmailHelper = new EmailAddressHelper(); userModel.AddToMediators(filter.AddToTeam.Value, filter.Report_id.Value); UserModel _um = new UserModel(filter.AddToTeam.Value); glb.UpdateReportLog(user.id, 5, filter.Report_id.Value, _um._user.first_nm + " " + _um._user.last_nm, null, ""); if ((_um._user.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(_um._user.email.Trim())) { List <string> to = new List <string>(); List <string> cc = new List <string>(); List <string> bcc = new List <string>(); to.Add(_um._user.email.Trim()); ReportModel _rm = new ReportModel(filter.Report_id.Value); EC.Business.Actions.Email.EmailManagement em = new EC.Business.Actions.Email.EmailManagement(); EC.Business.Actions.Email.EmailBody eb = new EC.Business.Actions.Email.EmailBody(1, 1, HttpContext.Current.Request.Url.AbsoluteUri.ToLower()); eb.MediatorAssigned(_um._user.first_nm, _um._user.last_nm, user.first_nm, user.last_nm, _rm._report.display_name); string body = eb.Body; em.Send(to, cc, LocalizationGetter.GetString("Email_Title_MediatorAssigned", false), body, true); } } if (filter.RemoveFromTeam.HasValue) { UserModel _um = new UserModel(filter.RemoveFromTeam.Value); int tasks_number = _um.UserTasks(1, filter.Report_id.Value, true).Count(); if (tasks_number == 0) { UserModel userModel = UserModel.inst; GlobalFunctions glb = new GlobalFunctions(); userModel.RemoveMediator(filter.RemoveFromTeam.Value, filter.Report_id.Value); glb.UpdateReportLog(user.id, 6, filter.Report_id.Value, _um._user.first_nm + " " + _um._user.last_nm, null, ""); } else { return(Get(filter.Report_id.Value, false, "User have a tasks")); } } if (filter.MakeCaseOwner.HasValue) { var list = DB.report_owner.Where(x => x.report_id == filter.Report_id).ToList(); foreach (var item in list) { item.status_id = item.user_id == filter.MakeCaseOwner.Value ? 2 : 1; } if (list.FirstOrDefault(x => x.user_id == filter.MakeCaseOwner.Value) == null) { DB.report_owner.Add(new report_owner { created_on = DateTime.Now, report_id = filter.Report_id.Value, user_id = filter.MakeCaseOwner.Value, status_id = 2, }); } DB.SaveChanges(); } return(Get(filter.Report_id.Value)); }
public ActionResult New(ReportViewModel model) { companyModel.ID = model.currentCompanyId; model.Process(Request.Form, Request.Files); var currentReport = reportModel.AddReport(model); ViewBag.CaseNumber = currentReport.display_name;//Request.Form["caseNumber"];model.caseNumber if (currentReport.user_id > 0) { var user = companyModel.GetUser(currentReport.user_id); ViewBag.UserId = user.id; /*model.userName = */ ViewBag.Login = user.login_nm; /*model.password = */ ViewBag.Password = user.password; /*model.userEmail = */ ViewBag.Email = user.email; SignIn(user); GlobalFunctions glb = new GlobalFunctions(); glb.UpdateReportLog(user.id, 2, currentReport.id, "", null, ""); glb.UpdateReportLog(user.id, 28, currentReport.id, App_LocalResources.GlobalRes._Started, null, ""); } ReportViewModel rvm = new ReportViewModel(); rvm.Merge(currentReport); ViewBag.companylogo = companyModel._company.path_en; ReportSubmit submit = new ReportSubmit(); submit.merge(rvm, companyModel, reportModel, model); ViewBag.ReportModel = new ReportModel(currentReport.id); #region SendEmail To Admins ReportModel rm = new ReportModel(currentReport.id); Business.Actions.Email.EmailManagement em = new Business.Actions.Email.EmailManagement(); Business.Actions.Email.EmailBody eb = new Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower()); bool has_involved = false; List <string> to = new List <string>(); List <string> cc = new List <string>(); if (rm.InvolvedMediatorsUserList().Count > 0) { has_involved = true; } string body = ""; string title = LocalizationGetter.GetString("Email_Title_NewCase"); if (has_involved) { title = LocalizationGetter.GetString("Email_Title_NewCaseInvolved"); } foreach (var _user in rm.MediatorsWhoHasAccessToReport().Where(t => t.role_id != 4).ToList()) { eb = new Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower()); to = new List <string>(); to.Add(_user.email.Trim()); if (has_involved) { eb.NewCaseInvolved(_user.first_nm, _user.last_nm, rm._report.display_name); } else { eb.NewCase(_user.first_nm, _user.last_nm, rm._report.display_name); } body = eb.Body; em.Send(to, cc, title, body, true); } #endregion return(View("CaseSubmitted", submit)); }
public object Get([FromUri] Filter filter) { var _started = DateTime.Now; user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker]; if (user == null || user.id == 0) { return(null); } UserModel um = new UserModel(user.id); UsersReportIDsViewModel vmAllIDs = um.GetAllUserReportIdsLists(); UsersUnreadReportsNumberViewModel vmUnreadReports = um.GetUserUnreadCasesNumbers(vmAllIDs); ///old var report_ids = um.ReportsSearchIds(um._user.company_id, filter.ReportFlag); List <int> report_ids = new List <int>(); switch (filter.ReportFlag) { case 1: //active report_ids = vmAllIDs.all_active_report_ids; break; case 2: //completed report_ids = vmAllIDs.all_completed_report_ids; break; case 5: //closed report_ids = vmAllIDs.all_closed_report_ids; break; case 3: //spam report_ids = vmAllIDs.all_spam_report_ids; break; case 4: //pending report_ids = vmAllIDs.all_pending_report_ids; break; default: report_ids = vmAllIDs.all_report_ids; break; } string investigation_status = LocalizationGetter.GetString("Investigation"); int delay_allowed = 2; if (report_ids.Count > 0) { ReportModel tempRm = new ReportModel(report_ids[0]); investigation_status = tempRm.InvestigationStatusString(); delay_allowed = tempRm.GetDelayAllowed(); } if (investigation_status.ToLower().Contains(LocalizationGetter.GetString("Investigation").ToLower())) { investigation_status = LocalizationGetter.GetString("Investigation"); } ////// var reports = report_ids.Select(x => new CasePreviewViewModel(x, user.id)).ToList(); var reports = um.ReportPreviews(report_ids, investigation_status, delay_allowed).ToList(); string title = LocalizationGetter.GetString("ActiveCasesUp"); title = filter.ReportFlag == 2 ? LocalizationGetter.GetString("CompletedcasesUp") : title; title = filter.ReportFlag == 5 ? LocalizationGetter.GetString("ClosedCasesUp") : title; title = filter.ReportFlag == 3 ? LocalizationGetter.GetString("SpamcasesUp") : title; title = filter.ReportFlag == 4 ? LocalizationGetter.GetString("NewReportsUp") : title; var m = new { Mode = filter.ReportFlag, Reports = reports, Counts = new { Active = vmUnreadReports.unread_active_reports, Completed = vmUnreadReports.unread_completed_reports, Spam = vmUnreadReports.unread_spam_reports, Closed = vmUnreadReports.unread_closed_reports, Pending = vmUnreadReports.unread_pending_reports, }, Title = title, counter = (DateTime.Now - _started).TotalMilliseconds, }; return(ResponseObject2Json(m)); }