コード例 #1
0
        [HttpPut] //Update a Statement
        public JsonResult Put(StatementDto vm)
        {
            //If ViewModel is invalid
            var errorMsg = GetModelErrors();

            if (!String.IsNullOrEmpty(errorMsg))
            {
                return(Json(ControllerHelper.TranslateErrorToClient(Result.Fail(errorMsg)), JsonRequestBehavior.AllowGet));
            }

            Result <int> result = _svc.Update(vm);

            return(Json(ControllerHelper.TranslateErrorToClient(result), JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task AddStatement()
        {
            // Arrange
            testsUtils.CleanAll();
            DateTime currentDateTime = DateTime.Parse("2018-04-21");

            var sut = BuildStatementController();

            // Act
            StatementDto dto = new StatementDto(0, currentDateTime, "test description dto", 200, "new dto category");
            await sut.AddStatement(dto);

            // Assert
            var category = dbUtils.GetAll <DbCategoryDto>().Single();

            Assert.Equal(dto.Category, category.Name);

            var statement = dbUtils.GetAll <DbStatementDto>().Single();

            Assert.Equal(dto.Amount, statement.Amount);
            Assert.Equal(dto.Description, statement.Description);
            Assert.Equal(dto.DueDate, statement.DueDate);
            Assert.Equal(category.Id, statement.CategoryId);
        }
コード例 #3
0
        public async Task AddStatement(StatementDto statement)
        {
            await statementController.AddStatement(statement);

            await BroadcastOverview();
        }