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 vm = RestaurantViewModel.Parse(getOperation.Result); ViewData["Title"] = "Restaurant"; var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "New", Controller = "Restaurants", Icon = "fa-search", Text = "Detail" }); 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 = RestaurantViewModel.Parse(item); return(Ok(vm)); }
public void TestCreateAndListRestaurantAsync() { RestaurantSeeder.Seed(); var dbo = new RestaurantBusinessObject(); var dr = new Restaurant("asdasd", "owewq", "123", "1232", "23ed", 4); var resCreate = dbo.CreateAsync(dr).Result; var resGet = dbo.ReadAsync(dr.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestCreateAndReadRestaurantAsync() { RestaurantSeeder.SeedCountries(); var bo = new RestaurantBusinessObject(); var rt = new Restaurant("Jade", "Avenida da Liberdade antes da rotunda", "13h00", "23h00", "monday", 24); var resCreate = bo.CreateAsync(rt).Result; var resGet = bo.ReadAsync(rt.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(NotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(View("Error", new ErrorViewModel() { RequestId = getOperation.Exception.Message })); } if (getOperation.Result == null) { return(NotFound()); } var vm = RestaurantViewModel.Parse(getOperation.Result); return(View(vm)); }
private async Task <RestaurantViewModel> GetRestaurantViewModel(Guid id) { var getOperation = await _rbo.ReadAsync(id); return(RestaurantViewModel.Parse(getOperation.Result)); }