Пример #1
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNotDeletedAsync();

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

            var lst = new List <ShoppingBasketViewModel>();

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

            var pList = await GetProfileViewModels(listOperation.Result.Select(x => x.ProfileId).Distinct().ToList());

            ViewData["Profiles"] = pList;

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

            return(View(lst));
        }
        public void TestDeleteEstablishmentAsync()
        {
            ContextSeeder.Seed();
            var bo        = new ShoppingBasketBusinessObject();
            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);
        }
Пример #3
0
        public void TestUpdateShoppingBasketAsync()
        {
            ContextSeeder.Seed();
            var bo      = new ShoppingBasketBusinessObject();
            var resList = bo.ListAsync().Result;
            var item    = resList.Result.FirstOrDefault();
            var pbo     = new ProfileBusinessObject();
            var pro     = pbo.List().Result.FirstOrDefault();

            item.ProfileId = pro.Id;
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().ProfileId == pro.Id);
        }
        public void TestUpdateShoppingBasketAsync()
        {
            ContextSeeder.Seed();
            var bo  = new ShoppingBasketBusinessObject();
            var ebo = new EstablishmentBusinessObject();
            var rbo = new RegionBusinessObject();
            var cbo = new CompanyBusinessObject();
            var reg = rbo.ListAsync().Result.Result.FirstOrDefault();
            var com = cbo.ListAsync().Result.Result.FirstOrDefault();
            var est = new Establishment("rua das papoilas", "09h00", "20h00", "sundays and holidays", reg.Id, com.Id);

            ebo.Create(est);
            var resList = bo.ListAsync();
            var item    = resList.Result.Result.FirstOrDefault();

            item.EstablishmentId = est.Id;
            var resUpdate  = bo.UpdateAsync(item).Result;
            var resNotList = bo.ListNotDeletedAsync().Result.Result;

            Assert.IsTrue(resUpdate.Success && resNotList.First().EstablishmentId == est.Id);
        }
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNotDeletedAsync();

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

            var lst = new List <ProductUnitViewModel>();

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

            var listEOperation = await _ebo.ListNotDeletedAsync();

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

            var elst = new List <EstablishmentViewModel>();

            foreach (var item in listEOperation.Result)
            {
                elst.Add(EstablishmentViewModel.Parse(item));
            }

            var listSBOperation = await _sbbo.ListNotDeletedAsync();

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

            var sblst = new List <ShoppingBasketViewModel>();

            foreach (var item in listSBOperation.Result)
            {
                sblst.Add(ShoppingBasketViewModel.Parse(item));
            }

            var eList = await GetEstablishmentViewModels(listOperation.Result.Select(x => x.EstablishmentId).Distinct().ToList());

            var sbList = await GetShoppingBasketViewModels(listOperation.Result.Select(x => x.ShoppingBasketId).Distinct().ToList());

            var pmList = await GetProductModelViewModels(listOperation.Result.Select(x => x.ProductModelId).Distinct().ToList());

            var cList = await GetCompanyViewModels(listEOperation.Result.Select(x => x.CompanyId).Distinct().ToList());

            var pList = await GetProfileViewModels(listSBOperation.Result.Select(x => x.ProfileId).Distinct().ToList());

            ViewData["Profiles"]        = pList;
            ViewData["Companies"]       = cList;
            ViewData["Establishments"]  = eList;
            ViewData["ShoppingBaskets"] = sbList;
            ViewData["ProductModels"]   = pmList;

            ViewData["Title"]       = "Product Units";
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            return(View(lst));
        }