Exemple #1
0
        public ActionResult Create([FromBody] EstablishmentViewModel vm)
        {
            var establishment = vm.ToModel();
            var res           = _bo.Create(establishment);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
        public void TestUpdateReservedQueue()
        {
            ContextSeeder.Seed();
            var regBo = new RegionBusinessObject();
            var reg   = new Region("Algordos");

            regBo.Create(reg);
            var compBo = new CompanyBusinessObject();
            var comp   = new Company("", 1234567890);

            compBo.Create(comp);
            var estBo = new EstablishmentBusinessObject();
            var est   = new Establishment("anywhere", "sempre", "nunca", "8º dia da semana", reg.Id, comp.Id);

            estBo.Create(est);
            var bo       = new ReservedQueueBusinessObject();
            var stoQList = bo.List();
            var item     = stoQList.Result.FirstOrDefault();

            item.EstablishmentId = est.Id;
            var stoQUpdate  = bo.Update(item);
            var stoQNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(stoQUpdate.Success && stoQNotList.First().EstablishmentId == est.Id);
        }
        public ActionResult Create([FromBody] EstablishmentViewModel vm)
        {
            var e = new Establishment(vm.Address, vm.OpeningHours, vm.ClosingHours, vm.ClosingDays, vm.RegionId,
                                      vm.CompanyId);

            var res = _bo.Create(e);

            return(res.Success ? Ok() : InternalServerError());
        }
        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);
        }
Exemple #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);
        }
Exemple #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);
        }
        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 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 void TestCreateAndReadStoreQueueAsync()
        {
            ContextSeeder.Seed();
            var regBo = new RegionBusinessObject();
            var reg   = new Region("Algordos");

            regBo.Create(reg);
            var compBo = new CompanyBusinessObject();
            var comp   = new Company("", 1234567890);

            compBo.Create(comp);
            var estBo = new EstablishmentBusinessObject();
            var est   = new Establishment("anywhere", "sempre", "nunca", "8º dia da semana", reg.Id, comp.Id);

            estBo.Create(est);
            var bo         = new StoreQueueBusinessObject();
            var storeQueue = new StoreQueue(32, est.Id);
            var stoQCreate = bo.CreateAsync(storeQueue).Result;
            var stoQGet    = bo.ReadAsync(storeQueue.Id).Result;

            Assert.IsTrue(stoQCreate.Success && stoQGet.Success && stoQGet.Result != null);
        }
        public void TestUpdateReservedQueueAsync()
        {
            ContextSeeder.Seed();
            var bo      = new ReservedQueueBusinessObject();
            var resList = bo.ListAsync().Result;
            var item    = resList.Result.FirstOrDefault();
            var comp2   = new Company("pingo sulfúrico", 123456798);
            var reg2    = new Region("Covilhona");
            var est2    = new Establishment("rua do ópio", "09h00", "20h00", "sundays and holidays", reg2.Id, comp2.Id);
            var cbo     = new CompanyBusinessObject();

            cbo.Create(comp2);
            var rbo = new RegionBusinessObject();

            rbo.Create(reg2);
            var ebo = new EstablishmentBusinessObject();

            ebo.Create(est2);
            item.EstablishmentId = est2.Id;
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().EstablishmentId == est2.Id);
        }