예제 #1
0
        public void TestCreateAndListProfileAsync()
        {
            ApplicationSeeder.Seed();

            var bo      = new ProfileBO();
            var profile = new Profile("John Doe", "Portugal", DateTime.Now);

            var resCreate = bo.CreateAsync(profile).Result;
            var resGet    = bo.ReadAsync(profile.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
예제 #2
0
        public async Task <IActionResult> New(ProfileVM vm)
        {
            if (ModelState.IsValid)
            {
                var model           = vm.ToProfile();
                var createOperation = await _bo.CreateAsync(model);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }

                return(OperationSuccess("The record was successfully created."));
            }
            return(View(vm));
        }