Пример #1
0
        public bool DeleteMail(int id, aspnet_Users user, out string msg)
        {
            bool res  = false;
            var  item = new udovika_email();

            try
            {
                if (!GetPermissionAccessMail(user))
                {
                    msg = "Недостаточно прав.";
                    return(res);
                }
                else
                {
                    db.DeleteMail(id);
                    res = true;
                    msg = "Сообщение удалено.";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Ошибка. Сообщение не удалено.";
            }
            return(res);
        }
Пример #2
0
        public bool CreateMail(string from, string to, aspnet_Users user, out string msg)
        {
            bool res  = false;
            var  mail = new udovika_email();

            msg = "";
            try
            {
                if (!GetPermissionAccessMail(user))
                {
                    msg = "Недостаточно прав.";
                    return(res);
                }
                else
                {
                    mail = new udovika_email()
                    {
                        id   = 0,
                        from = from,
                        to   = to,
                        date = DateTime.Now
                    };
                    SaveMail(mail, user, out msg);
                    res = true;
                    msg = "Сообщение создано.";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, mail, "");
                msg = "Не удалось создать сообщение.";
            }
            return(res);
        }
Пример #3
0
        public ActionResult Mail_Create(string trackNum, string from, string to,
                                        string backNum, string system, string description)
        {
            var msg  = "";
            var user = mng.GetUser();
            var item = new udovika_email();

            item.id          = 0;
            item.trackNum    = trackNum;
            item.description = description;
            item.statusID    = 1;
            item.date        = DateTime.Now.Date;
            item.from        = from;
            item.to          = to;
            item.backDate    = DateTime.Now.Date;
            item.backNum     = backNum;
            item.system      = system;

            var res = mng.Mail.SaveMail(item, user, out msg);

            return(Json(new
            {
                result = item.id > 0,
                saveID = item.id,
            }, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
 public int SaveMail(udovika_email mail)
 {
     if (mail.id == 0)
     {
         db.udovika_email.Add(mail);
         Save();
     }
     else
     {
         db.Entry(mail).State = System.Data.Entity.EntityState.Modified;
         Save();
     }
     return(mail.id);
 }
Пример #5
0
        public ActionResult EditMail(udovika_email mail)
        {
            var msg  = "";
            var user = mng.GetUser();
            var res  = mng.Mail.SaveMail(mail, user, out msg);

            if (res > 0)
            {
                return(Json(new { result = true }));
            }
            else
            {
                return(Json(new { result = false, msg = msg }));
            }
        }
Пример #6
0
        public udovika_email GetMail(int id, aspnet_Users user, out string msg)
        {
            msg = "";
            var item = new udovika_email();

            try
            {
                if (!GetPermissionAccessMail(user))
                {
                    msg = "Недостаточно прав.";
                    return(item = null);
                }
                item = GetMails().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { id = id }, "");
            }
            return(item);
        }
Пример #7
0
 public int SaveMail(udovika_email mail, aspnet_Users user, out string msg)
 {
     msg = "";
     try
     {
         if (!GetPermissionAccessMail(user))
         {
             msg = "Недостаточно прав.";
             return(0);
         }
         else
         {
             db.SaveMail(mail);
         }
     }
     catch (Exception ex)
     {
         _debug(ex, new { }, "");
     }
     return(mail.id);
 }