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); }
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)); }
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 })); }
public void SaveMail(Mikhailova_mails item) { try { db.SaveMail(item); } catch (Exception ex) { RDL.Debug.LogError(ex); } }
public void SaveMail(Mikhailova_mails item) { try { _db.SaveMail(item); } catch (Exception ex) { _debug(ex, new object { }, ""); } }
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); }
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); }
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); }