Exemple #1
0
        public void TestCreateAndListServiceAsync()
        {
            ApplicationSeeder.Seed();

            var bo      = new ServiceBO();
            var service = new Service("Moving property", "Transporting property/belongings", true);

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

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public async Task <IActionResult> New(ServiceVM vm)
        {
            if (ModelState.IsValid)
            {
                var model           = vm.ToService();
                var createOperation = await _bo.CreateAsync(model);

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

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