Example #1
0
        public void TestDeleteRegions()
        {
            ContextSeeder.Seed();
            var bo         = new RegionBusinessObject();
            var resList    = bo.List();
            var resDelete  = bo.Delete(resList.Result.First().Id);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted).ToList();

            Assert.IsTrue(resDelete.Success && resNotList.Count == 0);
        }
Example #2
0
        public void TestListRegions()
        {
            ContextSeeder.Seed();
            var bo      = new RegionBusinessObject();
            var resList = bo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
Example #3
0
        public void TestCreateSameNameRegion()
        {
            ContextSeeder.Seed();
            var bo        = new RegionBusinessObject();
            var item      = bo.List().Result.FirstOrDefault();
            var reg       = new Region(item.Name);
            var resCreate = bo.Create(reg);

            Assert.IsTrue(resCreate.Success);
        }
Example #4
0
        public void TestUpdateRegions()
        {
            ContextSeeder.Seed();
            var bo      = new RegionBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.Name = "another";
            var resUpdate  = bo.Update(item);
            var resNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(resUpdate.Success && resNotList.First().Name == "another");
        }
Example #5
0
        public void TestDeleteEstablishment()
        {
            var boReg  = new RegionBusinessObject();
            var boComp = new CompanyBusinessObject();
            var reg1   = boReg.List().Result.First();
            var com1   = boComp.List().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);
        }
Example #6
0
        public void TestCreateReadEstablishment()
        {
            ContextSeeder.Seed();
            var boReg = new RegionBusinessObject();
            var reg1  = boReg.List().Result.First();

            var boComp = new CompanyBusinessObject();
            var com1   = boComp.List().Result.First();

            var bo        = new EstablishmentBusinessObject();
            var est       = new Establishment("Avenida da liberdade, numero 1029, 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);
        }
Example #7
0
        public ActionResult <List <RegionViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(InternalServerError());
            }
            var list = new List <RegionViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(RegionViewModel.Parse(item));
            }
            return(list);
        }
        public ActionResult <List <RegionViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            var list = new List <RegionViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(new RegionViewModel {
                    Id = item.Id, Name = item.Name
                });
            }
            return(list);
        }
Example #9
0
        public void TestUpdateEstablishment()
        {
            ContextSeeder.Seed();

            var boReg = new RegionBusinessObject();
            var reg1  = boReg.List().Result.First();

            var boComp = new CompanyBusinessObject();
            var com1   = boComp.List().Result.First();

            var bo      = new EstablishmentBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.Address = "Rua Augusta, n 1213, Lisboa";
            var resUpdate  = bo.Update(item);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted);

            Assert.IsTrue(resUpdate.Success && resNotList.First().Address == "Rua Augusta, n 1213, Lisboa");
        }
        public void TestUpdateShoppingBasket()
        {
            ContextSeeder.Seed();
            var bo  = new ShoppingBasketBusinessObject();
            var ebo = new EstablishmentBusinessObject();
            var rbo = new RegionBusinessObject();
            var cbo = new CompanyBusinessObject();
            var reg = rbo.List().Result.FirstOrDefault();
            var com = cbo.List().Result.FirstOrDefault();
            var est = new Establishment("rua das papoilas", "09h00", "20h00", "sundays and holidays", reg.Id, com.Id);

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

            item.EstablishmentId = est.Id;
            var resUpdate  = bo.Update(item);
            var resNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(resUpdate.Success && resNotList.First().EstablishmentId == est.Id);
        }