コード例 #1
0
        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));
        }