Exemplo n.º 1
0
 public static ExerciseForm CreateExerciseForm(MovementForm form)
 {
     return(new ExerciseForm
     {
         MovementForm = form
     });
 }
Exemplo n.º 2
0
        private void movementFormBtn_Click(object sender, EventArgs e)
        {
            MovementForm movementForm = new MovementForm(this.ccToolbar);

            movementForm.Show();
            movementForm.TopMost = true;
        }
Exemplo n.º 3
0
        public void Create_WhenGivenADeposit_ThenTheBalanceIsIncreasedAndANewMovementIsCreated()
        {
            var options = new DbContextOptionsBuilder <ExpensesContext>()
                          .UseInMemoryDatabase(databaseName: "Create_WhenGivenADeposit_ThenTheBalanceIsIncreasedAndANewMovementIsCreated")
                          .Options;

            using (var expensesContext = new ExpensesContext(options))
            {
                expensesContext.Categories.Add(new Category("Foo"));
                var controller = new MovementsController(expensesContext);

                var form = new MovementForm
                {
                    Amount     = 100,
                    Type       = "deposit",
                    CategoryId = 1
                };
                var result = controller.Create(form);

                Assert.IsAssignableFrom <JsonResult>(result);
                dynamic json = ((JsonResult)result).Value;
                //Assert.Equal(100M, (decimal)json.balance);
                //Assert.Equal(100M, (decimal)json.movement.amount);
                Assert.Equal(1, expensesContext.Movements.ToArray().Length);
                Assert.Equal(100M, expensesContext.Movements.Sum(m => m.Amount));
            }
        }
Exemplo n.º 4
0
        void movementPanelBtn_actionEvent()
        {
            MovementForm movementForm = new MovementForm(this.ccToolbar);

            movementForm.StartPosition = FormStartPosition.CenterScreen;
            movementForm.ShowDialog();
            movementForm.TopMost = true;
        }
Exemplo n.º 5
0
        public IActionResult Create(MovementForm form)
        {
            var category = this.mExpensesContext.Categories.Find(form.CategoryId);
            var amount   = form.Amount * (form.Type == "expense" ? -1 : 1);

            byte[] picture;
            using (var ms = new MemoryStream())
            {
                form.Picture?.CopyTo(ms);
                picture = ms.ToArray();
            }

            var movement = new Movement(amount, form.Reason, category, picture, form.CreatedOn);

            this.mExpensesContext.Movements.Add(movement);
            this.mExpensesContext.SaveChanges();

            var balance = this.mExpensesContext.Movements.Sum(m => m.Amount);

            return(this.Json(new { movement = movement, balance = balance }));
        }