コード例 #1
0
        public void TestDeleteCompanyAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CompanyBusinessObject();
            var resList   = bo.ListNotDeletedAsync().Result;
            var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == 0);
        }
コード例 #2
0
        public void TestUpdateCompanyAsync()
        {
            ContextSeeder.Seed();
            var bo      = new CompanyBusinessObject();
            var resList = bo.ListNotDeletedAsync().Result;
            var item    = resList.Result.FirstOrDefault();

            item.Name = "Jerónimo Martins";
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == "Jerónimo Martins");
        }
コード例 #3
0
        public void TestCreateSameVatNumberCompanyAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CompanyBusinessObject();
            var item      = bo.ListNotDeletedAsync().Result.Result.First();
            var est       = new Company("Ilhas", item.VatNumber);
            var resCreate = bo.CreateAsync(est).Result;

            Assert.IsTrue(resCreate.Success);
        }
コード例 #4
0
        public async Task<IActionResult> Create()
        {
            var listROperation = await _rbo.ListNotDeletedAsync();
            if (!listROperation.Success) return OperationErrorBackToIndex(listROperation.Exception);
            var rList = new List<SelectListItem>();
            foreach (var item in listROperation.Result)
            {
                rList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Name });
            }
            ViewBag.Regions = rList;

            var listCOperation = await _cbo.ListNotDeletedAsync();
            if (!listCOperation.Success) return OperationErrorBackToIndex(listCOperation.Exception);
            var cList = new List<SelectListItem>();
            foreach (var item in listCOperation.Result)
            {
                cList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Name });
            }
            ViewBag.Companies = cList;

            Draw("Create", "fa-plus");
            return View();
        }
コード例 #5
0
        public void TestCreateSameAddressRegionAsync()
        {
            ContextSeeder.Seed();
            var bo        = new EstablishmentBusinessObject();
            var boReg     = new RegionBusinessObject();
            var boComp    = new CompanyBusinessObject();
            var reg1      = boReg.ListNotDeletedAsync().Result.Result.First();
            var com1      = boComp.ListNotDeletedAsync().Result.Result.First();
            var item      = bo.ListNotDeletedAsync().Result.Result.FirstOrDefault();
            var est       = new Establishment(item.Address, "9h00", "21h00", "monday", reg1.Id, com1.Id);
            var resCreate = bo.CreateAsync(est).Result;

            Assert.IsTrue(resCreate.Success);
        }
コード例 #6
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNotDeletedAsync();

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

            var lst = new List <CompanyViewModel>();

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

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

            return(View(lst));
        }