public void TestToUpdatedMoneyFlow()
        {
            var sourceEntityId = 2;
            var entityTypeId   = MoneyFlowSourceRecipientType.Project.Id;
            var model          = new UpdatedMoneyFlowBindingModel
            {
                Description       = "desc",
                FiscalYear        = 2015,
                Id                = 1,
                MoneyFlowStatusId = MoneyFlowStatus.Actual.Id,
                TransactionDate   = DateTimeOffset.UtcNow,
                Amount            = 1.00m,
                GrantNumber       = "grant",
                IsDirect          = true
            };
            var user     = new User(1);
            var instance = model.ToUpdatedMoneyFlow(user, sourceEntityId, entityTypeId);

            Assert.IsTrue(Object.ReferenceEquals(user, instance.Audit.User));
            Assert.AreEqual(model.Description, instance.Description);
            Assert.AreEqual(model.FiscalYear, instance.FiscalYear);
            Assert.AreEqual(model.Id, instance.Id);
            Assert.AreEqual(model.MoneyFlowStatusId, instance.MoneyFlowStatusId);
            Assert.AreEqual(model.TransactionDate, instance.TransactionDate);
            Assert.AreEqual(model.Amount, instance.Value);
            Assert.AreEqual(sourceEntityId, instance.SourceOrRecipientEntityId);
            Assert.AreEqual(entityTypeId, instance.SourceOrRecipientEntityTypeId);
            Assert.AreEqual(model.GrantNumber, instance.GrantNumber);
            Assert.AreEqual(model.IsDirect, instance.IsDirect);
        }
Exemple #2
0
        private async Task <IHttpActionResult> DoUpdateAsync(UpdatedMoneyFlowBindingModel model, int sourceEntityId, int sourceEntityTypeId)
        {
            if (ModelState.IsValid)
            {
                var currentUser  = this.userProvider.GetCurrentUser();
                var businessUser = this.userProvider.GetBusinessUser(currentUser);
                await this.moneyFlowService.UpdateAsync(model.ToUpdatedMoneyFlow(businessUser, sourceEntityId, sourceEntityTypeId));

                await this.moneyFlowService.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }