Beispiel #1
0
        public bool DeleteMail(int id, out string msg, pdv_contractors user)
        {
            bool res  = false;
            var  mail = new pdv_mails();

            try
            {
                mail = GetMail(id);
                if (mail != null)
                {
                    if (mail.contractorFromID != user.id)
                    {
                        msg = "Нет прав на удаление письма";
                        return(res);
                    }
                    mail.isDeleted = true;
                    SaveMail(mail);
                    res = true;
                    msg = "Письмо удалено";
                }
                else
                {
                    msg = "Не удалось найти письмо";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Ошибка удаления письма";
            }
            return(res);
        }
Beispiel #2
0
 public void SaveMail(pdv_mails item)
 {
     try
     {
         _db.SaveMail(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new object { }, "");
     }
 }
Beispiel #3
0
        public pdv_mails GetMail(int id)
        {
            var res = new pdv_mails();

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

            if (withSave)
            {
                Save();
            }
            return(element.id);
        }
Beispiel #5
0
        public bool CreateMail(int contractorFromID, int contractorToID)
        {
            bool res  = false;
            var  mail = new pdv_mails();

            try
            {
                mail = new pdv_mails
                {
                    id               = 0,
                    createDate       = DateTime.Now,
                    contractorFromID = contractorFromID,
                    contractorToID   = contractorToID
                };
                SaveMail(mail);
            }
            catch (Exception ex)
            {
                _debug(ex, new object { }, "");
            }
            return(res);
        }