public ActionResult Create([FromBody] MenuViewModel vm) { var rt = vm.ToMenu(); var res = _bo.Create(rt); return(res.Success ? Ok() : InternalServerError()); }
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 ActionResult Create([FromBody] MenuViewModel vm) { var dr = new Menu(vm.Date, vm.RestaurantId, vm.MealId); var res = _bo.Create(dr); var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError; return(new ObjectResult(code)); }
public ActionResult Create([FromBody] MenuViewModel vm) { var m = vm.ToMenu(); var res = _bo.Create(m); if (res.Success) { return(Ok()); } return(StatusCode((int)HttpStatusCode.InternalServerError)); }
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); }
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); }
public void TestCreateMenu() { 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.Create(menu); var resGet = mbo.Read(menu.Id); Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }