Beispiel #1
0
        public void TestCreateAndReadShoppingBasketAsync()
        {
            ContextSeeder.Seed();
            var bo        = new ShoppingBasketBusinessObject();
            var pbo       = new ProfileBusinessObject();
            var pro       = pbo.ListAsync().Result.Result.FirstOrDefault();
            var sb        = new ShoppingBasket(pro.Id);
            var resCreate = bo.CreateAsync(sb).Result;
            var resGet    = bo.ReadAsync(sb.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public void TestCreateAndReadShoppingBasketAsync()
        {
            ContextSeeder.Seed();
            var bo        = new ShoppingBasketBusinessObject();
            var ebo       = new EstablishmentBusinessObject();
            var resList   = ebo.List();
            var item      = resList.Result.FirstOrDefault();
            var sb        = new ShoppingBasket(item.Id);
            var resCreate = bo.CreateAsync(sb).Result;
            var resGet    = bo.ReadAsync(sb.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Beispiel #3
0
        public async Task <IActionResult> Create(ShoppingBasketViewModel vm)
        {
            var listROperation = await _pbo.ListNotDeletedAsync();

            if (!listROperation.Success)
            {
                return(OperationErrorBackToIndex(listROperation.Exception));
            }
            var pList = new List <SelectListItem>();

            foreach (var item in listROperation.Result)
            {
                pList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.VatNumber.ToString()
                });
            }

            ViewBag.Profiles = pList;

            Draw("Create", "fa-plus");

            if (ModelState.IsValid)
            {
                var model           = vm.ToShoppingBasket();
                var createOperation = await _bo.CreateAsync(model);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }
                else
                {
                    return(OperationSuccess("The record was successfuly created"));
                }
            }
            return(View(vm));
        }