public void TestDeleteRestaurantAsync()
        {
            ContextSeeders.Seed();
            var bo        = new RestaurantBusinessObject();
            var resList   = bo.List();
            var resDelete = bo.Delete(resList.Result.First().Id);

            resList = bo.List();
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted);
        }
        public void TestDeleteRestaurant()
        {
            RestaurantSeeder.SeedCountries();
            var bo         = new RestaurantBusinessObject();
            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);
        }
        public void TestUpdateRestaurant()
        {
            RestaurantSeeder.SeedCountries();
            var bo      = new RestaurantBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.OpeningHours = "9h00";
            var resUpdate  = bo.Update(item);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted);

            Assert.IsTrue(resUpdate.Success && resNotList.First().OpeningHours == "9h00");
        }
        public void TestUpdateRestaurant()
        {
            ContextSeeders.Seed();
            var bo      = new RestaurantBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.Name = "Ratatouille";
            var resUpdate  = bo.Update(item);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted);

            Assert.IsTrue(resUpdate.Success && resNotList.First().Name == "Ratatouille");
        }
        public void TestUpdateRestaurantAsync()
        {
            ContextSeeders.Seed();
            var mbo     = new RestaurantBusinessObject();
            var resList = mbo.List();
            var item    = resList.Result.FirstOrDefault();

            var newRestaurant = new Restaurant("Bartolomeu", "Rua tulipa, numero 234, Ericeira", "11:00", "22:00",
                                               "Segunfa-feira", 20);

            item.Name          = newRestaurant.Name;
            item.Address       = newRestaurant.Address;
            item.OpenningHours = newRestaurant.OpenningHours;
            item.ClosingHours  = newRestaurant.ClosingHours;
            item.ClosingDays   = newRestaurant.ClosingDays;
            item.TableCount    = newRestaurant.TableCount;


            var resUpdate = mbo.UpdateAsync(item).Result;

            resList = mbo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().Name == newRestaurant.Name &&
                          resList.Result.First().Address == newRestaurant.Address &&
                          resList.Result.First().OpenningHours == newRestaurant.OpenningHours &&
                          resList.Result.First().ClosingHours == newRestaurant.ClosingHours &&
                          resList.Result.First().ClosingDays == newRestaurant.ClosingDays &&
                          resList.Result.First().TableCount == newRestaurant.TableCount);
        }
        public void TestListRestaurant()
        {
            RestaurantSeeder.SeedCountries();
            var bo      = new RestaurantBusinessObject();
            var resList = bo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
示例#7
0
        public void TestDeleteRestaurant()
        {
            RestaurantSeeder.Seed();
            var bo        = new RestaurantBusinessObject();
            var resList   = bo.List();
            var resDelete = bo.Delete(resList.Result.First().Id);

            resList = bo.ListNonDeleted();
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == 0);
        }
示例#8
0
        public void TestUpdateRestaurant()
        {
            RestaurantSeeder.Seed();
            var bo      = new RestaurantBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

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

            resList = bo.ListNonDeleted();
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == "another");
        }
示例#9
0
        public void TestCreateAndReadStaffRecordAsync()
        {
            RestaurantSeeder.SeedCountries();
            var bo        = new StaffRecordBusinessObject();
            var bop       = new PersonBusinessObject();
            var pe1       = bop.List().Result.First();
            var bor       = new RestaurantBusinessObject();
            var rs1       = bor.List().Result.First();
            var dr        = new StaffRecord(DateTime.Parse("2020/05/05"), DateTime.Parse("2020/06/06"), pe1.Id, rs1.Id);
            var resCreate = bo.CreateAsync(dr).Result;
            var resGet    = bo.ReadAsync(dr.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public void TestCreateAndReadClientRecord()
        {
            RestaurantSeeder.SeedCountries();
            var bo        = new ClientRecordBusinessObject();
            var bop       = new PersonBusinessObject();
            var personId  = bop.List().Result.First();
            var rop       = new RestaurantBusinessObject();
            var resId     = rop.List().Result.First();
            var dr        = new ClientRecord(DateTime.Parse("2020/05/05"), personId.Id, resId.Id);
            var resCreate = bo.Create(dr);
            var resGet    = bo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#11
0
        public ActionResult <List <RestaurantViewModel> > List()
        {
            var res = _bo.List();

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

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

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

            foreach (var restaurant in res.Result)
            {
                list.Add(RestaurantViewModel.Parse(restaurant));
            }
            return(list);
        }
示例#13
0
        public void TestCreateAndListMenu()
        {
            RestaurantSeeder.Seed();
            var mbo  = new MealBusinessObject();
            var rbo  = new RestaurantBusinessObject();
            var mebo = new MenuBusinessObject();

            var m = mbo.List().Result.First();
            var r = rbo.List().Result.First();

            var dr        = new Menu(DateTime.Now, r.Id, m.Id);
            var resCreate = mebo.Create(dr);
            var resGet    = mebo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#14
0
        public void TestCreateAndListClientRecord()
        {
            RestaurantSeeder.Seed();
            var sbo = new ClientRecordBusinessObject();
            var rbo = new RestaurantBusinessObject();
            var pbo = new PersonBusinessObject();

            var r = rbo.List().Result.First();
            var p = pbo.List().Result.First();


            var dr        = new ClientRecord(p.Id, r.Id, DateTime.Now);
            var resCreate = sbo.Create(dr);
            var resGet    = sbo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }