示例#1
0
        public ActionResult Create([FromBody] RestaurantViewModel vm)
        {
            var rt  = vm.ToRestaurant();
            var res = _bo.Create(rt);

            return(res.Success ? Ok() : InternalServerError());
        }
示例#2
0
        public void TestCreateStaffRecordAsync()
        {
            ContextSeeders.Seed();
            var srbo = new StaffRecordBusinessObject();
            var pbo  = new PersonBusinessObject();
            var rbo  = new RestaurantBusinessObject();
            var lubo = new LennyouseUserBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());

            lubo.Create(_lennyouseUser);

            var _person = new Person(1234321, 23432456, "Marco", "Figueirnha", DateTime.UtcNow, _lennyouseUser.Id);

            pbo.Create(_person);

            var _restaurant = new Restaurant("Tasca do sol", "Bairro Alto 2", "12h", "00h", "Mondays", 3);

            rbo.Create(_restaurant);

            var _staffRecord = new StaffRecord(DateTime.UtcNow, DateTime.UtcNow, _person.Id, _restaurant.Id);

            var resCreate = srbo.CreateAsync(_staffRecord).Result;
            var resGet    = srbo.ReadAsync(_staffRecord.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public void TestCreateClientRecordAsync()
        {
            ContextSeeders.Seed();
            var crbo = new ClientRecordBusinessObject();
            var lubo = new LennyouseUserBusinessObject();
            var pbo  = new PersonBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());

            lubo.Create(_lennyouseUser);

            var _person = new Person(123456789, 934657823, "Miguel", "Silva", DateTime.UtcNow, _lennyouseUser.Id);

            pbo.Create(_person);

            var rbo        = new RestaurantBusinessObject();
            var _resturant = new Restaurant("Dom Pedro", "Rua das Flores 2", "2 p.m", "9 p.m", "Fridays", 2);

            rbo.Create(_resturant);

            var _clientRecord = new ClientRecord(DateTime.UtcNow, _person.Id, _resturant.Id);

            var resCreate = crbo.CreateAsync(_clientRecord).Result;
            var resGet    = crbo.ReadAsync(_clientRecord.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#4
0
            public void TestCreateServingAsync()
            {
                ContextSeeders.Seed();
                var sbo = new ServingBusinessObject();

                var rbo    = new RestaurantBusinessObject();
                var mealbo = new MealBusinessObject();
                var drbo   = new DietaryRestrictionBusinessObject();
                var mbo    = new MenuBusinessObject();
                var cbo    = new CourseBusinessObject();
                var dbo    = new DishBusinessObject();

                var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
                var meal       = new Meal("a", "b", "c");
                var dr         = new DietaryRestriction("ok");
                var menu       = new Menu(DateTime.Now, restaurant.Id, meal.Id);
                var course     = new Course("yes");
                var dish       = new Dish("uh", dr.Id);

                rbo.Create(restaurant);
                mealbo.Create(meal);
                drbo.Create(dr);
                mbo.Create(menu);
                cbo.Create(course);
                dbo.Create(dish);

                var serving = new Serving(menu.Id, course.Id, dish.Id);

                var resCreate = sbo.CreateAsync(serving).Result;
                var resGet    = sbo.ReadAsync(serving.Id).Result;

                Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
            }
        public void TestCreateBookingAsync()
        {
            ContextSeeders.Seed();
            var crbo  = new ClientRecordBusinessObject();
            var bbo   = new BookingBusinessObject();
            var pbo   = new PersonBusinessObject();
            var rbo   = new RestaurantBusinessObject();
            var lhubo = new LennyouseUserBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());
            var newP           = new Person(11111, 11111, "ok", "ok", DateTime.UtcNow, _lennyouseUser.Id);
            var newR           = new Restaurant("ok", "ok", "ok", "ok", "ok", 5);



            var cr      = new ClientRecord(DateTime.UtcNow, newP.Id, newR.Id);
            var booking = new Booking(cr.Id, DateTime.UtcNow);



            crbo.Create(cr);
            pbo.Create(newP);
            rbo.Create(newR);
            lhubo.Create(_lennyouseUser);

            var resCreate = bbo.CreateAsync(booking).Result;
            var resGet    = bbo.ReadAsync(booking.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#6
0
        public ActionResult Create([FromBody] RestaurantViewModel vm)
        {
            var r   = vm.ToRestaurant();
            var res = _bo.Create(r);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
示例#7
0
        public void TestUpdateMenu()
        {
            ContextSeeders.Seed();
            var mbo     = new MenuBusinessObject();
            var resList = mbo.List();
            var item    = resList.Result.FirstOrDefault();

            var rbo    = new RestaurantBusinessObject();
            var mealbo = new MealBusinessObject();

            var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
            var meal       = new Meal("a", "b", "c");

            rbo.Create(restaurant);
            mealbo.Create(meal);

            var newMenu = new Menu(DateTime.Now, restaurant.Id, meal.Id);

            item.Date         = newMenu.Date;
            item.RestaurantId = newMenu.RestaurantId;
            item.MealId       = newMenu.MealId;

            var resUpdate = mbo.Update(item);

            resList = mbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().Date == newMenu.Date && resList.Result.First().RestaurantId == newMenu.RestaurantId &&
                          resList.Result.First().MealId == newMenu.MealId);
        }
        public void TestCreateRestaurant()
        {
            ContextSeeders.Seed();
            var bo         = new RestaurantBusinessObject();
            var restaurant = new Restaurant("Lennyouse", "Rua alhusta, numero 456, Lisboa", "12:00", "23:00", "Segunda", 30);
            var resCreate  = bo.Create(restaurant);

            Assert.IsTrue(resCreate.Success);
        }
        public ActionResult Create([FromBody] RestaurantViewModel vm)
        {
            var r = new Restaurant(vm.Name, vm.Address, vm.OpenningHours, vm.ClosingHours, vm.ClosingDays, vm.TableCount);

            var res  = _bo.Create(r);
            var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError;

            return(new ObjectResult(code));
        }
        public void TestCreateAndReadRestaurant()
        {
            RestaurantSeeder.SeedCountries();
            var bo        = new RestaurantBusinessObject();
            var rs        = new Restaurant("Jade", "Avenida da Liberdade antes da rotunda", "13h00", "23h00", "monday", 24);
            var resCreate = bo.Create(rs);
            var resGet    = bo.Read(rs.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#11
0
        public void TestCreateAndListRestaurant()
        {
            RestaurantSeeder.Seed();
            var dbo       = new RestaurantBusinessObject();
            var dr        = new Restaurant("asdasd", "owewq", "123", "1232", "23ed", 4);
            var resCreate = dbo.Create(dr);
            var resGet    = dbo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
示例#12
0
            public void TestUpdateServingAsync()
            {
                ContextSeeders.Seed();
                var sbo     = new ServingBusinessObject();
                var resList = sbo.List();
                var item    = resList.Result.FirstOrDefault();

                var rbo    = new RestaurantBusinessObject();
                var mealbo = new MealBusinessObject();
                var drbo   = new DietaryRestrictionBusinessObject();
                var mbo    = new MenuBusinessObject();
                var cbo    = new CourseBusinessObject();
                var dbo    = new DishBusinessObject();

                var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
                var meal       = new Meal("a", "b", "c");
                var dr         = new DietaryRestriction("ok");
                var menu       = new Menu(DateTime.Now, restaurant.Id, meal.Id);
                var course     = new Course("yes");
                var dish       = new Dish("uh", dr.Id);

                rbo.Create(restaurant);
                mealbo.Create(meal);
                drbo.Create(dr);
                mbo.Create(menu);
                cbo.Create(course);
                dbo.Create(dish);

                var newServing = new Serving(menu.Id, course.Id, dish.Id);

                item.MenuId   = newServing.MenuId;
                item.CourseId = newServing.CourseId;
                item.DishId   = newServing.DishId;

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

                resList = sbo.ListAsync().Result;

                Assert.IsTrue(resList.Success && resUpdate.Success &&
                              resList.Result.First().MenuId == newServing.MenuId && resList.Result.First().CourseId == newServing.CourseId &&
                              resList.Result.First().DishId == newServing.DishId);
            }
示例#13
0
        public void TestUpdateStaffRecord()
        {
            ContextSeeders.Seed();
            var srbo    = new StaffRecordBusinessObject();
            var resList = srbo.List();
            var item    = resList.Result.FirstOrDefault();

            var pbo  = new PersonBusinessObject();
            var rbo  = new RestaurantBusinessObject();
            var lubo = new LennyouseUserBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());

            lubo.Create(_lennyouseUser);

            var _person = new Person(3654324444, 0000000, "Marco", "Figueirnha", DateTime.UtcNow, _lennyouseUser.Id);

            pbo.Create(_person);

            var _restaurant = new Restaurant("Tasca da Lua", "Bairro Alto 2", "12h", "00h", "Mondays", 7);

            rbo.Create(_restaurant);


            var _newStaffRecord = new StaffRecord(DateTime.UtcNow, DateTime.UtcNow, _person.Id, _restaurant.Id);

            item.BeginDate    = _newStaffRecord.BeginDate;
            item.EndDate      = _newStaffRecord.EndDate;
            item.PersonId     = _newStaffRecord.PersonId;
            item.RestaurantId = _newStaffRecord.RestaurantId;

            var resUpdate = srbo.Update(item);

            resList = srbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().BeginDate == _newStaffRecord.BeginDate &&
                          resList.Result.First().EndDate == _newStaffRecord.EndDate &&
                          resList.Result.First().PersonId == _newStaffRecord.PersonId &&
                          resList.Result.First().RestaurantId == _newStaffRecord.RestaurantId
                          );
        }
示例#14
0
        public void TestCreateMenuAsync()
        {
            ContextSeeders.Seed();
            var mbo = new MenuBusinessObject();

            var rbo    = new RestaurantBusinessObject();
            var mealbo = new MealBusinessObject();

            var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
            var meal       = new Meal("a", "b", "c");

            rbo.Create(restaurant);
            mealbo.Create(meal);

            var menu = new Menu(DateTime.Now, restaurant.Id, meal.Id);

            var resCreate = mbo.CreateAsync(menu).Result;
            var resGet    = mbo.ReadAsync(menu.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        public void TestUpdateBookingAsync()
        {
            ContextSeeders.Seed();
            var bbo     = new BookingBusinessObject();
            var resList = bbo.List();
            var item    = resList.Result.FirstOrDefault();


            var crbo  = new ClientRecordBusinessObject();
            var pbo   = new PersonBusinessObject();
            var rbo   = new RestaurantBusinessObject();
            var lhubo = new LennyouseUserBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());
            var newP           = new Person(11111, 11111, "ok", "ok", DateTime.UtcNow, _lennyouseUser.Id);
            var newR           = new Restaurant("ok", "ok", "ok", "ok", "ok", 5);



            var cr      = new ClientRecord(DateTime.UtcNow, newP.Id, newR.Id);
            var booking = new Booking(cr.Id, DateTime.UtcNow);


            crbo.Create(cr);
            pbo.Create(newP);
            rbo.Create(newR);
            lhubo.Create(_lennyouseUser);


            item.ClientRecordId = booking.ClientRecordId;

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

            resList = bbo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().ClientRecordId == booking.ClientRecordId &&
                          resList.Result.First().Date == booking.Date);
        }
        public void TestUpdateClientRecord()
        {
            ContextSeeders.Seed();
            var crbo    = new ClientRecordBusinessObject();
            var resList = crbo.List();
            var item    = resList.Result.FirstOrDefault();

            var lubo = new LennyouseUserBusinessObject();
            var pbo  = new PersonBusinessObject();
            var rbo  = new RestaurantBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());

            lubo.Create(_lennyouseUser);

            var _person = new Person(98764321, 364857484, "Ana", "Pereira", DateTime.UtcNow, _lennyouseUser.Id);

            pbo.Create(_person);


            var _resturant = new Restaurant("Dona Ivone", "Rua dos Anjos 2", "2 p.m", "9 p.m", "Sundays", 2);

            rbo.Create(_resturant);

            var _newclientRecord = new ClientRecord(DateTime.UtcNow, _person.Id, _resturant.Id);

            item.RegisterDate = _newclientRecord.RegisterDate;
            item.PersonId     = _newclientRecord.PersonId;
            item.RestaurantId = _newclientRecord.RestaurantId;

            var resUpdate = crbo.Update(item);

            resList = crbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().RegisterDate == _newclientRecord.RegisterDate && resList.Result.First().RestaurantId == _newclientRecord.RestaurantId &&
                          resList.Result.First().PersonId == _newclientRecord.PersonId);
        }