Ejemplo n.º 1
0
        public void TestUpdateMeal()
        {
            RestaurantSeeder.Seed();
            var bo      = new MealBusinessObject();
            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");
        }
Ejemplo n.º 2
0
        public void TestUpdateMeal()
        {
            RestaurantSeeder.SeedCountries();
            var bo      = new MealBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

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

            Assert.IsTrue(resUpdate.Success && resNotList.First().StartingHours == "20h00");
        }
        public ActionResult Update([FromBody] MealViewModel rt)
        {
            var currentResult = _bo.Read(rt.Id);

            if (!currentResult.Success)
            {
                return(InternalServerError());
            }
            var current = currentResult.Result;

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

            if (current.Name == rt.Name && current.StartingHours == rt.StartingHours && current.EndingHours == rt.EndingHours)
            {
                return(NotModified());
            }

            if (current.Name != rt.Name)
            {
                current.Name = rt.Name;
            }

            if (current.StartingHours != rt.StartingHours)
            {
                current.StartingHours = rt.StartingHours;
            }

            if (current.EndingHours != rt.EndingHours)
            {
                current.EndingHours = rt.EndingHours;
            }

            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Ejemplo n.º 4
0
        public void TestUpdateMeal()
        {
            ContextSeeders.Seed();
            var mbo     = new MealBusinessObject();
            var resList = mbo.List();
            var item    = resList.Result.FirstOrDefault();

            var newMeal = new Meal("lasagna", "8pm", "10pm");

            item.Name          = newMeal.Name;
            item.StartingHours = newMeal.StartingHours;
            item.EndingHours   = newMeal.EndingHours;

            var resUpdate = mbo.Update(item);

            resList = mbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().Name == newMeal.Name && resList.Result.First().StartingHours == newMeal.StartingHours &&
                          resList.Result.First().EndingHours == newMeal.EndingHours);
        }
Ejemplo n.º 5
0
        public ActionResult Update([FromBody] MealViewModel m)
        {
            var currentResult = _bo.Read(m.Id);

            if (!currentResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var current = currentResult.Result;

            if (current == null)
            {
                return(NotFound());
            }
            if (current.Name == m.Name && current.StartingHours == m.StartingHours &&
                current.EndingHours == m.EndingHours)
            {
                return(new ObjectResult(HttpStatusCode.NotModified));
            }

            if (current.Name != m.Name)
            {
                current.Name = m.Name;
            }
            if (current.StartingHours != m.StartingHours)
            {
                current.StartingHours = m.StartingHours;
            }
            if (current.EndingHours != m.EndingHours)
            {
                current.EndingHours = m.EndingHours;
            }
            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }