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