public bool SetFieldStatus(int expenseId, string fieldname, bool included) { try { var provider = new ExpenseProvider(_context); var entity = provider.Retrieve(expenseId); if (entity != null) { if (fieldname == "IncludeOnStatement") { entity.IncludeOnStatement = included; provider.Update(entity.ExpenseId, entity); provider.Commit(); return(true); } else // not supported field; just ignore for now... { return(true); } } } catch { throw; } return(false); }
public override void Update(int id, ExpenseRevenueModel model) { try { var dataProvider = new ExpenseProvider(_context); var entity = dataProvider.Retrieve(model.ExpenseId); MapData(model, entity); dataProvider.Update(id, entity); } catch { throw; } }
public override void Delete(int id) { try { // entity deletion does not physically delete the record; it marks [IsDeletd] = true var dataProvider = new ExpenseProvider(_context); var entity = dataProvider.Retrieve(id); entity.IsDeleted = true; dataProvider.Update(id, entity); } catch { throw; } }
public RevenueApprovalStatus?BacktrackWorkflow(int expenseId, RevenueApprovalStatus state) { try { var dataProvider = new ExpenseProvider(_context); var entity = dataProvider.Retrieve(expenseId); var prevState = PrevState(state); if (entity != null && prevState != null) { entity.ApprovalStatus = prevState.Value; RetrackWorkflowSignature(entity, state); dataProvider.Update(expenseId, entity); dataProvider.Commit(); return(prevState); } } catch { throw; } return(null); }
public RevenueApprovalStatus?MoveWorkflow(int expenseId, RevenueApprovalStatus state) { try { var dataProvider = new ExpenseProvider(_context); var entity = dataProvider.Retrieve(expenseId); var nextState = NextState(state); if (entity != null && nextState != null) { entity.ApprovalStatus = state; SetWorkflowSignature(entity, state); dataProvider.Update(expenseId, entity); dataProvider.Commit(); return(nextState); } } catch { throw; } return(null); }
private bool CreateExpenseForTransaction(string propertyCode, double amount, DateTime transactionDate, string groupCategory, string category) { var provider = new ExpenseProvider(_dbContext); int groupId = provider.GetGroupByKey(propertyCode, groupCategory, transactionDate); if (groupId > 0) { amount = -Math.Round(amount, 2); var expense = new Expense { ExpenseDate = transactionDate, Category = category, ExpenseAmount = (float)amount, PropertyCode = propertyCode, ParentId = groupId, ApprovalStatus = RevenueApprovalStatus.Approved, ApprovedNote = string.Empty, ConfirmationCode = string.Empty, }; provider.Create(expense); var entity = provider.Retrieve(groupId); if (entity != null) { entity.ExpenseAmount += (float)amount; provider.Update(entity.ExpenseId, entity); } return(true); } else { return(false); } }