public motskin_contractors Create(Dictionary <string, string> parameters, aspnet_Users user, out string msg) { motskin_contractors res; msg = ""; try { if (!_IsCanUserChange(user)) { msg = "Нет прав для данной операции"; return(null); } res = new motskin_contractors(); _fillContractor(res, parameters); _db.SaveContractor(res); // сохраняем в бд } catch (Exception ex) { _debug(ex, new { userName = user.UserName }); res = null; msg = "Сбой при выполнении операции"; } return(res); }
public static bool DeleteContractor(int id) { motskin_contractors element = _contractors.FirstOrDefault(p => p.id == id); if (element != null) { _contractors.Remove(element); return(true); } return(false); }
private void _fillContractor(motskin_contractors item, Dictionary <string, string> parameters) { foreach (var key in parameters.Keys) { switch (key) { case "name": item.name = parameters[key]; break; } } }
public static int SaveContractor(motskin_contractors element, bool withSave = true) { if (element.id == 0) { element.id = _contractors.Count + 1; _contractors.Add(element); } else { int pos = _contractors.IndexOf(_contractors.FirstOrDefault(p => p.id == element.id)); if (pos >= 0) { _contractors[pos] = element; } } return(_contractors.Count); }
public int SaveContractor(motskin_contractors element, bool withSave = true) { #if !PSEUDO if (element.id == 0) { db.motskin_contractors.Add(element); if (withSave) { Save(); } } else { db.Entry(element).State = EntityState.Modified; if (withSave) { Save(); } } return(element.id); #else return(PseudoData.SaveContractor(element)); #endif }