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());
        }
Ejemplo n.º 2
0
        public void TestDeleteCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CategoryBusinessObject();
            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);
        }
Ejemplo n.º 3
0
        public void TestUpdateCategorynAsync()
        {
            ContextSeeder.Seed();
            var bo      = new CategoryBusinessObject();
            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");
        }
Ejemplo n.º 4
0
        public void TestUpdateSameBarCodeProductModelAsync()
        {
            ContextSeeder.Seed();
            var bo      = new ProductModelBusinessObject();
            var bra     = bo.ListNotDeletedAsync().Result.Result.First();
            var catBo   = new CategoryBusinessObject();
            var cat     = catBo.ListNotDeletedAsync().Result.Result.First();
            var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id);

            prodMod.BarCode = "506-1237-424";
            var resUpdate = bo.UpdateAsync(prodMod).Result;

            Assert.IsTrue(!resUpdate.Result);
        }
Ejemplo n.º 5
0
        public void TestCreateAndReadProductModelAsync()
        {
            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;

            var resGet = bo.ReadAsync(prodMod.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNotDeletedAsync();

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

            var lst = new List <CategoryViewModel>();

            foreach (var item in listOperation.Result)
            {
                lst.Add(CategoryViewModel.Parse(item));
            }
            ViewData["Title"]       = "Categories";
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            return(View(lst));
        }