Esempio n. 1
0
        public async void UpdateLicense_AtInitializedDbTable_UpdatedLicenseEqualExpectedLicense()
        {
            // arrange
            var license = GetLicense();

            fixture.db.Add(license);
            await fixture.db.SaveChangesAsync();

            var expected = new License
            {
                Id           = license.Id,
                ProductId    = 44440,
                Date         = DateTime.UtcNow,
                GovermentNum = 5050505
            };

            // act
            await logic.UpdateDataModelAsync(expected);

            // assert
            var actual = await fixture.db.License.FirstOrDefaultAsync(i => i.Id == expected.Id);

            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.ProductId, actual.ProductId);
            Assert.Equal(expected.Date, actual.Date);
            Assert.Equal(expected.GovermentNum, actual.GovermentNum);
        }
Esempio n. 2
0
        public async Task <IActionResult> EditSingleItem(License model)
        {
            var statusMessage = await logicValidation.CheckUpdateDataModelAsync(model);

            if (statusMessage.IsCompleted)
            {
                await logic.UpdateDataModelAsync(model);

                await logProvider.AddToLogAsync($"Updated license information (Id: {model.Id}).");

                return(RedirectToRoute(LicensesRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }