示例#1
0
 public ActionResult SendMessage(iproby.Models.message model)
 {
     if (Session["login"] != null)
     {
         iproby.Data_Model.message message = new iproby.Data_Model.message();
         DateTime Now = DateTime.Now;
         message.date_from = Now;
         string login           = Session["login"].ToString();
         var    customer_id_arr = (from a in db.customers
                                   where a.login == login
                                   select a);
         int customer_id = 0; int contact_id = 0;
         foreach (var item in customer_id_arr)
         {
             customer_id = item.customer_id;
             contact_id  = item.contact_id;
         }
         var contact_arr = (from a in db.contacts
                            where a.contact_id == contact_id
                            select a);
         string email = string.Empty;
         foreach (var item in contact_arr)
         {
             email = item.email;
         }
         message.from_customer_id = customer_id;
         message.to_customer_id   = model.to_customer;
         message.header           = model.header;
         message.text_mess        = model.text;
         db.messages.Add(message);
         db.SaveChanges();
         InformationController notification = new InformationController();
         notification.SendMail(email, "Вам пришло сообщение на сайте IPRO. Пожалуйста проверьте в личном кабинете.");
         if (model.form_flag != null && model.form_flag == 1)
         {
             return(RedirectToAction("Answer", "Message", new { message_id = model.message_id }));
         }
         else
         {
             return(View("~/Views/Status/SendMessageSuccess.cshtml"));
         }
     }
     else
     {
         return(View("~/Views/Status/NoAuthorization.cshtml"));
     }
 }
示例#2
0
 public ActionResult SendMessage(iproby.Models.message model)
 {
     if (Session["login"] != null)
     {
         iproby.Data_Model.message message = new iproby.Data_Model.message();
         DateTime Now = DateTime.Now;
         message.date_from = Now;
         string login = Session["login"].ToString();
         var customer_id_arr = (from a in db.customers
                                where a.login == login
                                select a);
         int customer_id = 0; int contact_id = 0;
         foreach (var item in customer_id_arr)
         {
             customer_id = item.customer_id;
             contact_id = item.contact_id;
         }
         var contact_arr = (from a in db.contacts
                            where a.contact_id == contact_id
                            select a);
         string email = string.Empty;
         foreach (var item in contact_arr)
         {
             email = item.email;
         }
         message.from_customer_id = customer_id;
         message.to_customer_id = model.to_customer;
         message.header = model.header;
         message.text_mess = model.text;
         db.messages.Add(message);
         db.SaveChanges();
         InformationController notification = new InformationController();
         notification.SendMail(email, "Вам пришло сообщение на сайте IPRO. Пожалуйста проверьте в личном кабинете.");
         if (model.form_flag != null && model.form_flag == 1) {
             return RedirectToAction("Answer", "Message", new { message_id = model.message_id});
         }
         else
         {
             return View("~/Views/Status/SendMessageSuccess.cshtml");
         }
     }
     else
     {
         return View("~/Views/Status/NoAuthorization.cshtml");
     }
 }