public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(RecordNotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var getRestOperation = await _rbo.ReadAsync(getOperation.Result.RestaurantId); if (!getRestOperation.Success) { return(OperationErrorBackToIndex(getRestOperation.Exception)); } if (getRestOperation.Result == null) { return(RecordNotFound()); } var getMealOperation = await _mbo.ReadAsync(getOperation.Result.MealId); if (!getMealOperation.Success) { return(OperationErrorBackToIndex(getMealOperation.Exception)); } if (getMealOperation.Result == null) { return(RecordNotFound()); } var vm = MenuViewModel.Parse(getOperation.Result); ViewData["Title"] = "Dish"; var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "Details", Controller = "Menus", Icon = "fa-search", Text = "Detail" }); ViewData["Restaurant"] = RestaurantViewModel.Parse(getRestOperation.Result); ViewData["Meal"] = MealViewModel.Parse(getMealOperation.Result); ViewData["BreadCrumbs"] = crumbs; return(View(vm)); }
public async Task <IActionResult> GetAsync(Guid id) { var getResult = await _bo.ReadAsync(id); if (!getResult.Success) { return(InternalServerError(getResult.Exception)); } var item = getResult.Result; if (item == null) { return(NotFound()); } var vm = MenuViewModel.Parse(item); return(Ok(vm)); }
public void TestCreateAndListMenuAsync() { RestaurantSeeder.Seed(); var mbo = new MealBusinessObject(); var rbo = new RestaurantBusinessObject(); var mebo = new MenuBusinessObject(); var m = mbo.ListAsync().Result.Result.First(); var r = rbo.ListAsync().Result.Result.First(); var dr = new Menu(DateTime.Now, r.Id, m.Id); var resCreate = mebo.CreateAsync(dr).Result; var resGet = mebo.ReadAsync(dr.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
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); }
private async Task <MenuViewModel> GetMenuViewModel(Guid id) { var getOperation = await _mbo.ReadAsync(id); return(MenuViewModel.Parse(getOperation.Result)); }