private molchanov_logInvoices _logInvoicesChanges(aspnet_Users user, molchanov_invoices element, string notice) { var res = new molchanov_logInvoices { date = DateTime.Now, userName = user.UserName, notice = "{element.number}: " + notice, invoiceID = element.id }; return(res); }
public molchanov_invoices CreateInvoice(Dictionary <string, string> parameters, out string msg, aspnet_Users user) { msg = ""; molchanov_invoices res; try { if (!_canManageItem(user)) { msg = "Нет прав создавать элемента"; res = null; } else { res = new molchanov_invoices(); res.uniqueCode = Guid.NewGuid(); res.isDeleted = false; foreach (var key in parameters.Keys) { if (key == "number") { res.number = parameters[key]; } else if (key == "date") { res.date = Convert.ToDateTime(parameters[key]); } else if (key == "description") { res.description = parameters[key]; } else if (key == "invoiceStatus") { res.invStatusID = RDL.Convert.StrToInt(parameters[key], 0); } else if (key == "contragentName") { res.contragentID = RDL.Convert.StrToInt(parameters[key], 0); } } _db.SaveInvoice(res); _db.SaveInvoiceLog(_logInvoicesChanges(user, res, "Счет создан")); } } catch (Exception e) { _debug(e, new { }, "Ошибка возникла при создании элемента"); res = null; } return(res); }
public int SaveInvoice(molchanov_invoices element, bool withSave = true) { if (element.id == 0) { db.molchanov_invoices.Add(element); if (withSave) { Save(); } } else { db.Entry(element).State = EntityState.Modified; if (withSave) { Save(); } } return(element.id); }
public int AddInvoice(molchanov_invoices element) { _invoicesList.Add(element); return(element.id); }