Ejemplo n.º 1
0
        public override int HandleTransaction(DataTransaction.ActionType type, Transaction obj)
        {
            switch (type)
            {
            case DataTransaction.ActionType.Create:
                accountsService.UpdateBalance(obj.Account, obj.Amount);
                break;

            case DataTransaction.ActionType.Edit:
                var transaction = context.Transactions.Where(t => t.Id == obj.Id).Single();
                accountsService.UpdateBalance(obj.Account, transaction.Amount - obj.Amount);
                break;

            case DataTransaction.ActionType.Delete:
                accountsService.UpdateBalance(obj.Account, -obj.Amount);
                break;
            }
            return(base.HandleTransaction(type, obj));
        }
Ejemplo n.º 2
0
        public virtual int HandleTransaction(DataTransaction.ActionType type, T obj)
        {
            switch (type)
            {
            case DataTransaction.ActionType.Create:
                return(Add(obj));

            case DataTransaction.ActionType.Delete:
                return(Remove(obj));

            case DataTransaction.ActionType.Edit:
                return(Update(obj));

            case DataTransaction.ActionType.Reset:
                return(ClearTable());

            default:
                throw new ArgumentException("Unkown transaction type: " + Enum.GetName(typeof(DataTransaction.ActionType), type));
            }
        }