public long UpdateInvoiceItem(InvoiceItemObject fee) { try { if (fee == null) { return(-2); } var invoiceItemEntity = ModelMapper.Map <InvoiceItemObject, InvoiceItem>(fee); if (invoiceItemEntity == null || invoiceItemEntity.Id < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.InvoiceItems.Attach(invoiceItemEntity); db.Entry(invoiceItemEntity).State = EntityState.Modified; db.SaveChanges(); return(fee.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddInvoiceItem(InvoiceItemObject fee) { try { if (fee == null) { return(-2); } var invoiceItemEntity = ModelMapper.Map <InvoiceItemObject, InvoiceItem>(fee); if (invoiceItemEntity == null || invoiceItemEntity.InvoiceId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.InvoiceItems.Add(invoiceItemEntity); db.SaveChanges(); return(returnStatus.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }