public bool UpdatePaymentMode(xPlug.BusinessObject.PaymentMode paymentMode) { try { //Re-Map Object to Entity Object var myEntityObj = PaymentModeMapper.Map <xPlug.BusinessObject.PaymentMode, PaymentMode>(paymentMode); if (myEntityObj == null) { return(false); } using (var db = new ExpenseManagerDBEntities()) { db.PaymentModes.Attach(myEntityObj); db.ObjectStateManager.ChangeObjectState(myEntityObj, EntityState.Modified); db.SaveChanges(); return(true); } } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(false); } }
public int AddPaymentMode(xPlug.BusinessObject.PaymentMode paymentMode) { try { //Re-Map Object to Entity Object var myEntityObj = PaymentModeMapper.Map <xPlug.BusinessObject.PaymentMode, PaymentMode>(paymentMode); if (myEntityObj == null) { return(-2); } using (var db = new ExpenseManagerDBEntities()) { db.AddToPaymentModes(myEntityObj); db.SaveChanges(); paymentMode.PaymentModeId = myEntityObj.PaymentModeId; return(paymentMode.PaymentModeId); } } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(0); } }