Exemple #1
0
        public ActionResult Update([FromBody] RestaurantViewModel restaurantView)
        {
            var currentResult = _bo.Read(restaurantView.Id);

            if (!currentResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            var current = currentResult.Result;

            if (current == null)
            {
                return(NotFound());
            }

            if (current.Name == restaurantView.Name && current.Address == restaurantView.Address &&
                current.OpeningHours == restaurantView.OpeningHours && current.ClosingHours == restaurantView.ClosingHours &&
                current.ClosedDays == restaurantView.ClosedDays && current.TableCount == restaurantView.TableCount)
            {
                return(StatusCode((int)HttpStatusCode.NotModified));
            }

            if (current.Name != restaurantView.Name)
            {
                current.Name = restaurantView.Name;
            }
            if (current.Address != restaurantView.Address)
            {
                current.Address = restaurantView.Address;
            }
            if (current.OpeningHours != restaurantView.OpeningHours)
            {
                current.OpeningHours = restaurantView.OpeningHours;
            }
            if (current.ClosingHours != restaurantView.ClosingHours)
            {
                current.ClosingHours = restaurantView.ClosingHours;
            }
            if (current.ClosedDays != restaurantView.ClosedDays)
            {
                current.ClosedDays = restaurantView.ClosedDays;
            }
            if (current.TableCount != restaurantView.TableCount)
            {
                current.TableCount = restaurantView.TableCount;
            }

            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
        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");
        }
Exemple #3
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");
        }
        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");
        }