Ejemplo n.º 1
0
 public LineExpenseChanged(Guid id, DateTime timestamp, LineId lineId, BudgetId budgetId, UserId updatedBy, Expense expense)
 {
     Id = id;
     Timestamp = timestamp;
     LineId = lineId;
     BudgetId = budgetId;
     UpdatedBy = updatedBy;
     Expense = expense;
 }
Ejemplo n.º 2
0
        public LineCreated(Guid id, DateTime timestamp, LineId lineId, BudgetId budgetId, UserId createdBy, Expense expense)
        {
            Id = id;
            Timestamp = timestamp;

            LineId = lineId;
            BudgetId = budgetId;
            Expense = expense;
            CreatedBy = createdBy;
        }
Ejemplo n.º 3
0
        public CreateLine ToCreateLine(DateTime timestamp, BudgetId budgetId, string userId, IEnumerable<MyBudget.Projections.Category> categories)
        {
            var category = Categoria.Trim().Replace((char)160, ' ');
            var categoryId = categories.FirstOrDefault(d => string.Compare(d.Name, category, true) == 0).Id;
            var expense = new Expense(new Amount(Currencies.Euro(), Spesa), Data, categoryId, Descrizione, DistributionKey);

            return new CreateLine
            {
                Id = Guid.NewGuid(),
                Timestamp = timestamp,
                BudgetId = budgetId.ToString(),
                LineId = LineId.Create(budgetId).ToString(),
                UserId = userId,
                Expense = expense,
                 
            };
        }
Ejemplo n.º 4
0
 public MyBudget.Commands.UpdateLine PrepareUpdateLine(string userId)
 {
     var expense = new Expense(new Amount(Currencies.Parse(CurrencyISOCode), Amount), Date, Category, Description, DistributionKey);
     return new MyBudget.Commands.UpdateLine
     {
         UserId = userId,
         BudgetId = BudgetId.ToString(),
         LineId = LineId.ToString(),
         Id = Guid.NewGuid(),
         Timestamp = DateTime.Now,
         Expense = expense,
     };
 }
Ejemplo n.º 5
0
        public void Update(Expense expense, UserId updatedBy)
        {
            if (string.IsNullOrEmpty(Id))
                throw new Exception("line does not exists");

            RaiseEvent(new LineExpenseChanged(Guid.NewGuid(), DateTime.Now, _state.GetLineId(), _state.GetBudgetId(), updatedBy, expense));
        }
Ejemplo n.º 6
0
        public void Create(LineId id, BudgetId budgetId, Expense expense, UserId createdBy)
        {
            if (string.IsNullOrEmpty(Id) == false)
                throw new Exception("line already exists");

            RaiseEvent(new LineCreated(Guid.NewGuid(), DateTime.Now, id, budgetId, createdBy, expense));
        }
Ejemplo n.º 7
0
        public static CreateLine ToCreateLine(this Movement mov, BudgetId budgetId, string userId, IEnumerable<MyBudget.Projections.Category> categories)
        {
            var category = mov.Category.Trim().Replace((char)160, ' ');
            var categoryId = categories.FirstOrDefault(d => string.Compare(d.Name, category, true) == 0).Id;

            var expense = new Expense(new Amount(Currencies.Euro(), Convert.ToDecimal(mov.Import)), mov.DateTime, categoryId, mov.ShortDescription);


            return new CreateLine
            {
                Id = Guid.NewGuid(),
                Timestamp = DateTime.Now,
                BudgetId = budgetId.ToString(),
                LineId = LineId.Create(budgetId).ToString(),
                UserId = userId,
                Expense = expense,
            };
        }