Exemplo n.º 1
0
        public object Get(int id)
        {
            user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker];

            if (user == null || user.id == 0)
            {
                return(null);
            }

            UserModel um = new UserModel(user.id);
            var       rm = new ReportModel(id);

            var mediators = new CaseMessagesModel(id, 2, user.id);
            var reporters = new CaseMessagesModel(id, 1, user.id);

            var m = new
            {
                mediators   = mediators.AllMessagesList.ToList(),
                reporters   = reporters.AllMessagesList.ToList(),
                currentUser = new
                {
                    photo_path = user.photo_path
                },
            };

            return(ResponseObject2Json(m));
        }
        // GET: Reporter Messages
        public ActionResult Messages(int?id)
        {
            user user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

            if (user == null || user.id == 0 || user.role_id == 4 || user.role_id == 5 || user.role_id == 6 || user.role_id == 7)
            {
                return(RedirectToAction("Index", "Account"));
            }

            //    ViewBag.user_id = id.Value; // 167-171
            id = user.id;

            if ((!id.HasValue) || (id.Value == 0))
            {
                return(RedirectToAction("Index", "Account"));
            }

            #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 = id.Value; // 167-171

            UserModel um        = new UserModel(id.Value);
            int       report_id = um._reporter_report_id;
            ViewBag.report_id = report_id;
            ViewBag.user_id   = id.Value;

            ReportModel rm = new ReportModel(report_id);

            ViewBag.rm = rm;
            ViewBag.um = um;
            ViewBag.unread_message_number = um.Unread_Messages_Quantity(report_id, 1);

            CaseMessagesModel cm = new CaseMessagesModel(report_id, 1, id.Value);

            GlobalFunctions glb = new GlobalFunctions();
            glb.UpdateReadMessages(report_id, id.Value, 1);

            return(View(cm));
        }
        public ActionResult Messages([Bind(Include = "body_tx,report_id,sender_id,reporter_access")]  CaseMessagesModel cm)
        {
            temp_cm = cm;
            cm._message.created_dt = DateTime.Now;
            cm._message.ip_ds      = "";
            cm._message.subject_ds = "";

            return(View(cm));

            if (ModelState.IsValid)
            {
                /*         db.message.Add(newMessage);
                 *       try
                 *       {
                 *           db.SaveChanges();
                 *           glb.UpdateReportLog(newMessage.sender_id, 7, newMessage.report_id, "", null, "");
                 *
                 *           // send emails to Case Admin
                 *
                 #region Email to Case Admin
                 *           ReportModel rm = new ReportModel(newMessage.report_id);
                 *
                 *           foreach (user _user in rm.MediatorsWhoHasAccessToReport())
                 *           {
                 *               if ((_user.email.Trim().Length > 0) && glb.IsValidEmail(_user.email.Trim()))
                 *               {
                 *                   List<string> to = new List<string>();
                 *                   List<string> cc = new List<string>();
                 *                   List<string> bcc = new List<string>();
                 *
                 *                   to.Add(_user.email.Trim());
                 *                     ///     bcc.Add("*****@*****.**");
                 *
                 *                   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, Request.Url.AbsoluteUri.ToLower());
                 *                   eb.NewMessage(_user.first_nm, _user.last_nm, rm._report.display_name);
                 *                   string body = eb.Body;
                 *          ///////         em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_NewMessage, body, true);
                 *               }
                 *           }
                 *
                 *
                 #endregion
                 *
                 *       }
                 *       catch (Exception ex)
                 *       {
                 *           return View(newMessage);
                 *       }
                 * ////////           return RedirectToAction("Messages/" + newMessage.sender_id.ToString());
                 *       // return RedirectToAction("Messages/208");
                 */
            }

            user user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

            if (user == null || user.id == 0 || user.role_id == 4 || user.role_id == 5 || user.role_id == 6 || user.role_id == 7)
            {
                return(RedirectToAction("Index", "Account"));
            }

            //  return RedirectToAction("Messages/" + user.id.ToString());
            #region Commented --- Values in Session

            /*      EC.Models.App.Case.CaseMessagesModel cm1 = new Models.App.Case.CaseMessagesModel(newMessage.report_id, 1, newMessage.sender_id);
             *
             *
             *    user temp_user = (user)Session[Constants.CurrentUserMarcker];
             *    if (temp_user == null || temp_user.id == 0 || temp_user.role_id == 4 || temp_user.role_id == 5 || temp_user.role_id == 6 || temp_user.role_id == 7)
             *        return RedirectToAction("Index", "Account");
             *
             *
             *    //    ViewBag.user_id = id.Value; // 167-171
             *    int? id = user.id;
             *
             *    if ((!id.HasValue) || (id.Value == 0))
             *        return RedirectToAction("Index", "Account");
             *
             *    ViewBag.user_id = id.Value; // 167-171
             *
             *    UserModel um = new UserModel(id.Value);
             *    int report_id = um._reporter_report_id;
             *    ViewBag.report_id = report_id;
             *    ViewBag.user_id = id.Value;
             *
             *    return View(cm);
             * //   return Json(new { someValue = someValue });*/
            #endregion
        }