public int SaveStatusContract(Shtoda_statuses_contracts item, bool withSave = true) { var res = 0; try { res = _db.SaveStatusContract(item); } catch (Exception ex) { _debug(ex, new { item }, "item"); } return(res); }
public int SaveStatusContract(Shtoda_statuses_contracts element, bool withSave = true) { if (element.id == 0) { db.Shtoda_statuses_contracts.Add(element); } else { db.Entry(element).State = EntityState.Modified; } if (withSave) { Save(); } return(element.id); }
public bool EditDocumentStatusField(aspnet_Users user, int id, string code, string value, out string msg) { bool res = false; var documentStatus = new Shtoda_statuses_contracts(); try { if (!_IsCanUserChange(user)) { msg = "Недостаточна прав для редактирования!"; } else { documentStatus = GetStatusContract(id); if (documentStatus != null) { switch (code) { case "name": documentStatus.name = value; break; case "code": documentStatus.code = value; break; } SaveStatusContract(documentStatus); res = true; msg = "Успешно"; } else { msg = "Не удалось найти статус документ"; } } } catch (Exception ex) { _debug(ex, new { }, ""); msg = "Произошла ошибка, поле не изменено"; } return(res); }
public Shtoda_statuses_contracts GetStatusContract(int id) { var res = new Shtoda_statuses_contracts(); var key = "gl_docStatuses" + id; if (CacheManager.EnableCaching && CacheManager.Cache[key] != null) { res = (Shtoda_statuses_contracts)CacheManager.Cache[key]; } else { try { res = _db.GetStatusesContract().FirstOrDefault(x => x.id == id); CacheManager.CacheData(key, res); } catch (Exception ex) { _debug(ex, new { id }, "id"); } } return(res); }