Esempio n. 1
0
        public void TestUpdateCompany()
        {
            ContextSeeder.Seed();
            var bo      = new CompanyBusinessObject();
            var resList = bo.ListNotDeleted();
            var item    = resList.Result.FirstOrDefault();

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

            Assert.IsTrue(resUpdate.Success && resNotList.First().Name == "Jerónimo Martins");
        }
        public IActionResult Index()
        {
            var getRboOperation = _rbo.ListNotDeleted();
            var getCboOperation = _cbo.ListNotDeleted();


            var rList = new List <SelectListItem>();

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

            var cList = new List <SelectListItem>();

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

            ViewBag.Regions   = rList;
            ViewBag.Companies = cList;
            return(View());
        }
Esempio n. 3
0
        public void TestCreateSameVatNumberCompany()
        {
            ContextSeeder.Seed();
            var bo        = new CompanyBusinessObject();
            var item      = bo.ListNotDeleted().Result.First();
            var est       = new Company("Ilhas", item.VatNumber);
            var resCreate = bo.Create(est);

            Assert.IsTrue(resCreate.Success);
        }
        public void TestCreateSameAddressRegion()
        {
            ContextSeeder.Seed();
            var bo        = new EstablishmentBusinessObject();
            var boReg     = new RegionBusinessObject();
            var boComp    = new CompanyBusinessObject();
            var reg1      = boReg.ListNotDeleted().Result.First();
            var com1      = boComp.ListNotDeleted().Result.First();
            var item      = bo.ListNotDeleted().Result.FirstOrDefault();
            var est       = new Establishment(item.Address, "9h00", "21h00", "monday", reg1.Id, com1.Id);
            var resCreate = bo.Create(est);

            Assert.IsTrue(resCreate.Success);
        }
        public void TestUpdateSameNameEstablishmentAsync()
        {
            ContextSeeder.Seed();
            var boReg  = new RegionBusinessObject();
            var reg1   = boReg.ListNotDeleted().Result.First();
            var boComp = new CompanyBusinessObject();
            var com1   = boComp.ListNotDeleted().Result.First();
            var bo     = new EstablishmentBusinessObject();
            var est    = new Establishment("Avenida da liberdade, numero 1022, Lisboa", "09:00", "20:00", "Domingo", reg1.Id, com1.Id);

            bo.Create(est);
            est.Address = "Avenida da liberdade, numero 1029, Lisboa";
            var resUpdate = bo.UpdateAsync(est).Result;

            Assert.IsTrue(resUpdate.Success);
        }
        public void TestCreateReadEstablishment()
        {
            ContextSeeder.Seed();
            var boReg = new RegionBusinessObject();
            var reg1  = boReg.ListNotDeleted().Result.FirstOrDefault();

            var boComp = new CompanyBusinessObject();
            var com1   = boComp.ListNotDeleted().Result.FirstOrDefault();

            var bo        = new EstablishmentBusinessObject();
            var est       = new Establishment("Avenida da liberdade, numero 1022, Lisboa", "09:00", "20:00", "Domingo", reg1.Id, com1.Id);
            var resCreate = bo.Create(est);
            var resGet    = bo.Read(est.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public void TestDeleteEstablishment()
        {
            ContextSeeder.Seed();
            var boReg  = new RegionBusinessObject();
            var boComp = new CompanyBusinessObject();
            var reg1   = boReg.ListNotDeleted().Result.First();
            var com1   = boComp.ListNotDeleted().Result.First();

            var objEst = new EstablishmentBusinessObject();
            var est    = new Establishment("Rua da pitaia, numero 1234, Açores", "07:00",
                                           "20:00", "Domingo", reg1.Id, com1.Id);

            objEst.Create(est);
            var res = objEst.Delete(est);

            Assert.IsTrue(res.Success);
        }