Ejemplo n.º 1
0
		public async Task<ActionResult> List()
		{
			var model = new MealModel();
			var response = await _mealsService.GetMeals();

			return View(model.Adapt(response.Meals));
		}
Ejemplo n.º 2
0
		public async Task<ActionResult> Details(int id)
		{
			if (id == 0) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

			var model = new MealModel();
			var getMealResponse = await _mealsService.GetMealById(new GetMealRequest
			{
				MealId = id,
				CorrelationId = Guid.NewGuid().ToString(),
				Requestor = ClaimsPrincipal.Current.Identity.Name
			});

			if (getMealResponse.Meal == null) return HttpNotFound();

			return View(model.Adapt(getMealResponse.Meal));
		}
Ejemplo n.º 3
0
		public async Task<ActionResult> DeleteConfirmed(int id)
		{
			var model = new MealModel();
			var getMealResponse = await _mealsService.GetMealById(new GetMealRequest
			{
				MealId = id,
				CorrelationId = Guid.NewGuid().ToString(),
				Requestor = ClaimsPrincipal.Current.Identity.Name
			});
			if (getMealResponse.Meal.Menus.Any())
			{
				model = model.Adapt(getMealResponse.Meal);
				model.ErrorsOccured = true;
				model.ErrorMessage = "There are menus associated with this company.";
				return View(model);
			}
			await _mealsService.DeleteMeal(new DeleteMealRequest
			{
				MealId = id,
				CorrelationId = Guid.NewGuid().ToString(),
				Requestor = ClaimsPrincipal.Current.Identity.Name
			}).ConfigureAwait(false);
			return RedirectToAction("List");
		}