private molchanov_logDocTypes _logDocumentTypeChanges(aspnet_Users user, molchanov_docTypes element, string notice) { var res = new molchanov_logDocTypes { date = DateTime.Now, userName = user.UserName, notice = "{element.name}: " + notice, docTypeID = element.id }; return(res); }
public int SaveDocType(molchanov_docTypes element, bool withSave = true) { if (element.id == 0) { db.molchanov_docTypes.Add(element); if (withSave) { Save(); } } else { db.Entry(element).State = EntityState.Modified; if (withSave) { Save(); } } return(element.id); }
public molchanov_docTypes CreateDocType(Dictionary <string, string> parameters, out string msg, aspnet_Users user) { msg = ""; molchanov_docTypes res; try { if (!_canManageItem(user)) { msg = "Нет прав создавать элемента"; res = null; } else { res = new molchanov_docTypes(); foreach (var key in parameters.Keys) { if (key == "name") { res.name = parameters[key]; } else if (key == "code") { res.code = parameters[key]; } } _db.SaveDocType(res); _db.SaveDocTypeLog(_logDocumentTypeChanges(user, res, "Тип документа создан")); } } catch (Exception e) { _debug(e, new { }, "Ошибка возникла при создании элемента"); res = null; } return(res); }
public int AddDocTypes(molchanov_docTypes element) { _docTypesList.Add(element); return(element.id); }