예제 #1
0
        public bool DeleteMail(int id, out string msg, Mikhailova_contracts user)
        {
            bool res  = false;
            var  mail = new Mikhailova_mails();

            try
            {
                mail = GetMail(id);
                if (mail != null)
                {
                    if (mail.id != user.id) //
                    {
                        msg = "Нет прав на удаление письма";
                        return(res);
                    }
                    //mail.isDeleted = true; insert in db
                    SaveMail(mail);
                    res = true;
                    msg = "Письмо удалено";
                }
                else
                {
                    msg = "Не удалось найти письмо";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Ошибка удаления письма";
            }
            return(res);
        }
예제 #2
0
        public Mikhailova_mails GetMail(int id)
        {
            var res = new Mikhailova_mails();

            res = db.GetMail(id);
            return(res);
        }
        public ActionResult CreateMails(string treckNumber, string from, string to, string systemMail, string desc)
        {
            var mng      = new ContractsManager();
            int statusID = 1;
            var item     = new Mikhailova_mails
            {
                id                = 0,
                treckNumber       = treckNumber,
                date              = DateTime.Now.Date,
                from              = from,
                to                = to,
                statusID          = statusID,
                systemMail        = systemMail,
                treckNumberReplay = "",
                dateReplay        = DateTime.Now.Date,
                desc              = desc
            };

            mng.SaveMail(item);
            return(Json(new
            {
                result = item.id > 0,
                savedID = item.id,
            }, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
 public int SaveMail(Mikhailova_mails item)
 {
     try
     {
         if (item.id == 0)
         {
             db.Mikhailova_mails.Add(item);
             db.SaveChanges();
         }
         else
         {
             try
             {
                 db.Entry(item).State = EntityState.Modified;
                 db.SaveChanges();
             }
             catch (OptimisticConcurrencyException ex)
             {
                 RDL.Debug.LogError(ex);
             }
         }
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
     return(item.id);
 }
        public ActionResult EditMails(Mikhailova_mails item)
        {
            var mng = new ContractsManager();

            mng.SaveMail(item);

            return(Json(new { result = true }));
        }
예제 #6
0
 public void SaveMail(Mikhailova_mails item)
 {
     try
     {
         db.SaveMail(item);
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
 }
예제 #7
0
 public void SaveMail(Mikhailova_mails item)
 {
     try
     {
         _db.SaveMail(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new object { }, "");
     }
 }
예제 #8
0
        public Mikhailova_mails GetMail(int id)
        {
            var res = new Mikhailova_mails();

            try
            {
                res = _db.GetMails().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new object { }, "");
            }
            return(res);
        }
예제 #9
0
        public int SaveMail(Mikhailova_mails element, bool withSave = true)
        {
            if (element.id == 0)
            {
                db.Mikhailova_mails.Add(element);
            }
            else
            {
                db.Entry(element).State = EntityState.Modified;
            }

            if (withSave)
            {
                Save();
            }
            return(element.id);
        }
예제 #10
0
        public bool CreateMail(int contractorFromID, int contractorToID)
        {
            bool res  = false;
            var  mail = new Mikhailova_mails();

            try
            {
                mail = new Mikhailova_mails
                {
                    id   = 0,
                    date = DateTime.Now,
                    from = contractorFromID.ToString(),
                    to   = contractorToID.ToString()
                };
                SaveMail(mail);
            }
            catch (Exception ex)
            {
                _debug(ex, new object { }, "");
            }
            return(res);
        }