public async Task <IActionResult> Create()
        {
            var listBOperation = await _bbo.ListNotDeletedAsync();

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

            var listCOperation = await _cbo.ListNotDeletedAsync();

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


            var bList = new List <SelectListItem>();

            foreach (var item in listBOperation.Result)
            {
                bList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                });
            }

            var cList = new List <SelectListItem>();

            foreach (var item in listCOperation.Result)
            {
                cList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                });
            }
            ViewBag.Measure = Enum.GetNames(typeof(Measure)).Select(r => new SelectListItem {
                Text = r, Value = r
            });;

            ViewBag.Brands     = bList;
            ViewBag.Categories = cList;

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

            return(View());
        }
Exemplo n.º 2
0
        public void TestDeleteBrandAsync()
        {
            ContextSeeder.Seed();
            var bo        = new BrandBusinessObject();
            var resList   = bo.ListAsync().Result;
            var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == 0);
        }
Exemplo n.º 3
0
        public void TestUpdateBrandAsync()
        {
            ContextSeeder.Seed();
            var bo      = new BrandBusinessObject();
            var resList = bo.ListAsync().Result;
            var item    = resList.Result.FirstOrDefault();

            item.Name = "It's just wine";
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == "It's just wine");
        }
        public void TestCreateSameBarCodeProductModelAsync()
        {
            ContextSeeder.Seed();
            var braBo = new BrandBusinessObject();
            var bra   = braBo.ListNotDeletedAsync().Result.Result.First();
            var catBo = new CategoryBusinessObject();
            var cat   = catBo.ListNotDeletedAsync().Result.Result.First();

            var bo        = new ProductModelBusinessObject();
            var prodMod   = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id);
            var resCreate = bo.CreateAsync(prodMod).Result;

            Assert.IsTrue(!resCreate.Result);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNotDeletedAsync();

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

            var lst = new List <BrandViewModel>();

            foreach (var item in listOperation.Result)
            {
                lst.Add(BrandViewModel.Parse(item));
            }

            ViewData["Title"]       = "Brands";
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();

            return(View(lst));
        }