Exemplo n.º 1
0
        public bool DeleteMail(int id, out string msg, Shtoda_contracts user)
        {
            bool res  = false;
            var  mail = new Shtoda_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);
        }
Exemplo n.º 2
0
 public void SaveMail(Shtoda_mails item)
 {
     try
     {
         _db.SaveMail(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new object { }, "");
     }
 }
Exemplo n.º 3
0
        public Shtoda_mails GetMail(int id)
        {
            var res = new Shtoda_mails();

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

            if (withSave)
            {
                Save();
            }
            return(element.id);
        }
Exemplo n.º 5
0
        public bool CreateMail(int contractorFromID, int contractorToID)
        {
            bool res  = false;
            var  mail = new Shtoda_mails();

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