public ActionResult Edit(int?id) { ApplicationUser user = this.currentUserProvider.Get(); Recipient recipient = this.recipientProfileService.GetByApplicationUserId(user.Id); FoodRequest foodRequest = this.foodRequestService.GetById((int)id); if (recipient.Id != foodRequest.RecipientId) { return(RedirectToAction("Index")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (foodRequest == null) { return(HttpNotFound()); } FoodRequestEditModel model = Mapper.Map <FoodRequest, FoodRequestEditModel>(foodRequest); return(View(model)); }
private void SeedFoodRequests(ApplicationDbContext context, List <Recipient> recipients, List <FoodDonation> foodDonations) { if (context.FoodRequests.Any()) { return; } for (int i = 0; i < 20; i++) { for (int j = 1; j <= 20; j++) { var foodRequest = new FoodRequest(); var foodDonationIndex = this.randomGenerator.Next(0, foodDonations.Count); var foodDonation = foodDonations[foodDonationIndex]; foodRequest.Recipient = recipients[i]; foodRequest.FoodDonation = foodDonation; foodRequest.Quantity = j.ToString() + (j == 1 ? " item" : " items"); foodRequest.Description = foodDonation.Name; foodRequest.NeedFrom = DateTime.Now; foodRequest.NeedTo = foodDonation.AvailableTo; foodRequest.CreatedOn = DateTime.Now; context.FoodRequests.Add(foodRequest); } } context.SaveChanges(); }
public IActionResult Update(Guid id, [FromBody] FoodRequest request) { var food = nutritionRepository.GetFood(id); if (food.UserId != CurrentUserId) { if (!food.UserId.HasValue && FoodHasChanges(food, request)) { request.Name += " (oma)"; foreach (var portion in request.Portions) { portion.Id = Guid.Empty; } return(Create(request)); } return(Unauthorized()); } CheckNutrientPortion(request); Mapper.Map(request, food); CalculatePortionNutrients(request, food); nutritionRepository.UpdateFood(food); var response = Mapper.Map <FoodDetailsResponse>(food); return(Ok(response)); }
public ActionResult DeleteConfirmed(int id) { FoodRequest foodRequest = this.foodRequestService.GetById(id); this.foodRequestService.Delete(foodRequest); return(RedirectToAction("Index")); }
public async Task CreateFoodRequestAsync(FoodItemRequest foodItems) { GrpcChannel channel = GrpcChannel.ForAddress("http://*****:*****@response}", response); }
public override async Task <FoodResponse> CreateFood(FoodRequest request, ServerCallContext context) { List <string> items = new List <string>(); _logger.LogInformation("Begin grpc call from method {Method} for Foody Restaurant {RestaurantName}", context.Method, request.Foods.RestaurantName); request.Foods.FoodItems.ToList().ForEach(a => items.Add(a.Name)); var foodData = new FoodData(items, request.Foods.RestaurantName, request.Foods.Description); if (foodData != null) { await _repository.AddAsync(foodData); context.Status = new Status(StatusCode.OK, "Food created successfulyl."); _logger.LogInformation("Grpc call created successfully for Restaurant {RestaurantName}", request.Foods.RestaurantName); return(new FoodResponse { Message = "Food Created" }); } else { context.Status = new Status(StatusCode.NotFound, "Error creating food."); } return(new FoodResponse { Message = "Food Error." }); }
private async Task <List <MealDO> > GetRecomendationFromAIRabbit(FoodRequest request) { JArray array; string resultContent = await _rpcClient.SendAsync(JsonSerializer.Serialize(request)); array = JArray.Parse(resultContent); return(GetMealList(array)); }
private static void CheckNutrientPortion(FoodRequest request) { var nutrientPortion = request.Portions?.FirstOrDefault(p => p.NutrientPortion); if (nutrientPortion != null && nutrientPortion.Id == Guid.Empty) { nutrientPortion.Id = Guid.NewGuid(); } }
public IActionResult Create([FromBody] FoodRequest request) { CheckNutrientPortion(request); var food = Mapper.Map <FoodDetails>(request); food.UserId = CurrentUserId; CalculatePortionNutrients(request, food); nutritionRepository.CreateFood(food); var response = Mapper.Map <FoodDetailsResponse>(food); return(Ok(response)); }
public ActionResult Edit(FoodRequestEditModel model) { FoodRequest foodRequest = this.foodRequestService.GetById(model.Id); Mapper.Map <FoodRequestEditModel, FoodRequest>(model, foodRequest); if (ModelState.IsValid) { this.foodRequestService.Update(foodRequest); return(RedirectToAction("Index")); } return(View(model)); }
public AddFoodPageViewModel( INavigationService navigationService, IApiService apiService, IFilesHelper filesHelper) : base(navigationService) { _navigationService = navigationService; _apiService = apiService; _filesHelper = filesHelper; Title = "Add Food"; Image = App.Current.Resources["UrlNoImage"].ToString(); IsEnabled = true; Food = new FoodRequest(); TypeFoods = new ObservableCollection <TypeFoodResponse>(CombosHelper.GetTypeFood()); }
public int InsertFood_BL(FoodRequest food) { var idUser = _userRepository.GetUsuario(food.UserId); if (idUser.UsuarioId == 1) { return(0); } var foodEntity = _mapper.Map <AlimentoEntity>(food); var insertFood = _foodRepository.InsertFood_DAO(foodEntity); return(insertFood); }
public IActionResult Update(Guid id, [FromBody] FoodRequest request) { var food = nutritionRepository.GetFood(id); if (food.UserId != CurrentUserId) { return(Unauthorized()); } CheckNutrientPortion(request); AutoMapper.Mapper.Map(request, food); CalculatePortionNutrients(request, food); nutritionRepository.UpdateFood(food); var response = AutoMapper.Mapper.Map <FoodDetailsResponse>(food); return(Ok(food)); }
public IActionResult InsertFood([FromBody] FoodRequest foodRequest) { var response = _foodBL.InsertFood_BL(foodRequest); if (response != 0) { return(Ok(new Response { Message = "Alimento inserido com sucesso!" })); } else { return(NotFound(new Errors { errors = "Usuário não encontrado!" })); } }
// GET: Administration/FoodRequests/Edit/5 public ActionResult Edit(int?id) { FoodRequest foodRequest = this.foodRequestService.GetById((int)id); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (foodRequest == null) { return(HttpNotFound()); } FoodRequestEditModel model = Mapper.Map <FoodRequest, FoodRequestEditModel>(foodRequest); return(View(model)); }
private static bool FoodHasChanges(FoodDetails food, FoodRequest request) { if (food.Ean != request.Ean) { return(true); } if (food.Manufacturer != request.Manufacturer) { return(true); } if (food.Name != request.Name) { return(true); } if (food.Nutrients != null) { foreach (var nutrient in food.Nutrients) { var nutrient2 = request.Nutrients.FirstOrDefault(n => n.NutrientId == nutrient.NutrientId); if (nutrient2 == null || nutrient2.Amount != nutrient.Amount) { return(true); } } } if (food.Portions != null) { if (food.Portions.Length != (request.Portions?.Length ?? 0)) { return(true); } foreach (var portion in food.Portions) { var portion2 = request.Portions.FirstOrDefault(p => p.Id == portion.Id); if (portion2 == null || portion2.Name != portion.Name || portion2.Weight != portion.Weight) { return(true); } } } return(false); }
private static void CalculatePortionNutrients(FoodRequest request, FoodDetails food) { var nutrientPortion = request.Portions.FirstOrDefault(p => p.NutrientPortion); if (nutrientPortion != null) { food.NutrientPortionId = nutrientPortion.Id; var portionWeight = nutrientPortion.Weight; if (food.Nutrients != null) { foreach (var nutrientAmount in food.Nutrients) { nutrientAmount.PortionAmount = nutrientAmount.Amount; nutrientAmount.Amount *= (100m / portionWeight); } } } }
public async Task <IActionResult> GetFoods([FromBody] FoodRequest foodRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } List <FoodEntity> foodEntity = await _context.Foods .Include(m => m.TypeFoods) .Include(m => m.User) .Where(e => e.EstablishmentLocations.Id == foodRequest.EstablishmentLocationId) .ToListAsync(); if (foodEntity == null) { } return(Ok(_converterHelper.ToFoodResponse(foodEntity))); }
private async Task <List <MealDO> > GetRecomendationFromAIAsync(FoodRequest request) { JArray array; using (var client = new HttpClient()) { var httpRequest = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri(_uri + "/recomendation"), Content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json") }; var result = await client.SendAsync(httpRequest); string resultContent = await result.Content.ReadAsStringAsync(); array = JArray.Parse(resultContent); } return(GetMealList(array)); }
protected override CachedTask <FoodResponse> GetData(bool force, CancellationToken token) { if (!force) { return(CachedTask.NoNewData <FoodResponse>()); } var request = new FoodRequest { Language = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, MealTime = MealTime, Date = MealDate, UserName = _credentials.UserName }; Func <Task <FoodResponse> > getter = () => _menuService.GetMenusAsync(request, token); if (MealDate.Date == DateTime.Now.Date) { return(CachedTask.Create(getter, MealTime.GetHashCode(), DateTime.Now.Date.AddDays(1))); } return(CachedTask.DoNotCache(getter)); }
public async Task CreateGrpcFoodRequestAsync(FoodItemRequest foodItems) { _logger.LogInformation("grpc client created"); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true); GrpcChannel channel = GrpcChannel.ForAddress("https://*****:*****@response}", response); }
public void Add(FoodRequest foodRequest) { this.foodRequestRepository.Add(foodRequest); this.foodRequestRepository.SaveChanges(); }
public Task <FoodResponse> GetMenusAsync(FoodRequest request, CancellationToken cancellationToken) { return(Task.FromResult ( new FoodResponse { Status = FoodStatus.Success, Menu = new[] { new Restaurant { Name = "Atlantide", Rating = new Rating { Value = 0.75, VoteCount = 2 }, Meals = new[] { new Meal { Name = "Suprême de poulet (CH) sauce curry jaune", Description = @"Jardinière de légumes Riz parfumé Buffet de salades", MealTypes = new[] { MealType.Thai }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 9.50 }, { PriceTarget.Visitor, 12.00 }, { PriceTarget.PhDStudent, 9.50 }, { PriceTarget.Staff, 9.50 } }, HalfPortionPrice = 7.50, Rating = new Rating { Value = 1.00, VoteCount = 1 } } } }, new Restaurant { Name = "Cafétéria BC", Rating = new Rating { Value = 0.6, VoteCount = 10 }, Meals = new[] { new Meal { Name = "Ragout de porc (CH) mixed-grill au vinaigre balsamique", Description = @"Épinards en branches Pomme purée", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Tagliatelle au pesto et basilic, graines de courge", Description = @"Épinards en branches Salade mêlée", MealTypes = new[] { MealType.Vegetarian, MealType.Pasta }, Prices = new Dictionary <PriceTarget, double> { }, Rating = new Rating { Value = 0.66, VoteCount = 3 } }, new Meal { Name = "Piccata de dinde (CH), sauce à la tomate", Description = @"Épinards en branches Pomme purée Salade mêlée", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 12.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 1 } } } }, new Restaurant { Name = "Bistro 31", Rating = new Rating { Value = 1.0, VoteCount = 1 }, Meals = new[] { new Meal { Name = "Steak de Boeuf", Description = @"Haricots verts Pommes de terre au four Salade", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 25.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 1 } } } }, new Restaurant { Name = "Le Copernic", Rating = new Rating { Value = 0.90, VoteCount = 20 }, Meals = new[] { new Meal { Name = "Pavé de loup de mer à l'huile vierge", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 26.00 } }, Rating = new Rating { Value = 0.8, VoteCount = 5 } }, new Meal { Name = "Filet de rouget grondin", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 26.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, new Meal { Name = "Saladine d'oranges sanguine, sébaste aux crevettes", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 20.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Escalope de saumon poêlé à la piperade", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 18.50 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, new Meal { Name = "Pavé de boeuf Angus Irlandais, cuisson à votre convenance", Description = "", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 27.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Panzerrotti au jambon cru, crème de basilic", Description = "", MealTypes = new[] { MealType.Pasta }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 18.50 } }, Rating = new Rating { Value = 0.5, VoteCount = 1 } }, new Meal { Name = "Filet de volaille FR jaune farcie, sauce aux morilles", Description = "", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 25.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Tartare de boulgour ou Gaspacho comme un bloody Mary", Description = "", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 8.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Risotto de polenta aux pleurotes", Description = "Bol de salade", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 18.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } } } }, new Restaurant { Name = "Le Corbusier", Rating = new Rating { Value = 0.6, VoteCount = 5 }, Meals = new[] { new Meal { Name = "Cuisse de poulet à la diable(ch)", Description = @"Pommes frites Carottes Vichy ou salade ou potage", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 2 } }, new Meal { Name = "Fricandeaux aux petits oignons", Description = @"Pâtes au beurre Carottes Vichy Salade ou potage", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 11.00 }, { PriceTarget.Visitor, 11.00 }, { PriceTarget.PhDStudent, 11.00 }, { PriceTarget.Staff, 11.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, new Meal { Name = "Pojarki de veau grillé", Description = @"Pâtes au beurre Légume du jour Salade ou potage", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 9.00 }, { PriceTarget.Visitor, 10.00 }, { PriceTarget.PhDStudent, 11.00 }, { PriceTarget.Staff, 12.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Pizza ou pâtes fraiches maison", Description = @"sauce crème ou tomate garniture à choi Xaussi à l'emporter", MealTypes = new[] { MealType.Pizza }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 9.00 }, { PriceTarget.Visitor, 9.00 }, { PriceTarget.PhDStudent, 9.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "penne à la diavola", Description = @"Légumes,épices,tomate et sauge Salade ou potage", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } } } }, new Restaurant { Name = "L'Esplanade", Rating = new Rating { Value = 0.3, VoteCount = 10 }, Meals = new[] { new Meal { Name = "Steak de cheval(CA) Jus a la diable", Description = @"Haricots verts Pommes de terre au four", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.6, VoteCount = 5 } } } }, new Restaurant { Name = "Le Hodler", Rating = new Rating { Value = 0.85, VoteCount = 40 }, Meals = new[] { new Meal { Name = "Entrecôte de boeuf, double cheese burger", Description = @"Légumes du jour ou garniture du jour", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 14.00 } }, Rating = new Rating { Value = 0.9, VoteCount = 10 } }, new Meal { Name = "Hamburger", Description = @"Légumes du jour ou garniture du jour", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 12.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 2 } }, new Meal { Name = "Cheese burger", Description = @"Légumes du jour ou garniture du jour", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 12.50 } }, Rating = new Rating { Value = 0.5, VoteCount = 2 } }, new Meal { Name = "Marguerite CHF9.00", Description = @"Végétarienne, calzone, 3 fromages Reine Pizza de la semaine : roquette, poivrons, crevettes et parmesan", MealTypes = new[] { MealType.Pizza }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 10.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 1 } }, new Meal { Name = "Poitrine de poulet à l'ail d'ours", Description = @"Carottes persillées Riz pilaw", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, new Meal { Name = "Dal de lentilles corail", Description = @"aux épices douces Salade mêlée", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 10.00 } } } } }, new Restaurant { Name = "Hong Thai Rung", Rating = new Rating { Value = 0.68, VoteCount = 50 }, Meals = new[] { new Meal { Name = "Nouilles jaunes sautées aux crevettes", Description = "", MealTypes = new[] { MealType.Thai }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.00 } }, Rating = new Rating { Value = 0.7, VoteCount = 10 } }, new Meal { Name = "Boeuf (CH) sauté au basilic thaï", Description = "Riz parfumé", MealTypes = new[] { MealType.Meat, MealType.Thai }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.00 } }, Rating = new Rating { Value = 0.8, VoteCount = 5 } }, new Meal { Name = "Porc (CH) au curry rouge, lait de coco et ananas", Description = "Riz parfumé", MealTypes = new[] { MealType.Meat, MealType.Thai }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 4 } }, new Meal { Name = "Tofu et légumes sautés au gingembre", Description = "Riz parfumé", MealTypes = new[] { MealType.Vegetarian, MealType.Thai }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.00 } }, Rating = new Rating { Value = 0.75, VoteCount = 4 } } } }, new Restaurant { Name = "Maharaja", Rating = new Rating { Value = 0.8, VoteCount = 40 }, Meals = new[] { new Meal { Name = "Petits carrés de porc (CH) frits au piment", Description = @"Dhal (lentilles) Riz basmati", MealTypes = new[] { MealType.Meat, MealType.Indian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.50 } }, Rating = new Rating { Value = 1.0, VoteCount = 5 } }, new Meal { Name = "Mélange de légumes et d'épices assorties", Description = @"Raita (yogourt épicé) Riz basmati", MealTypes = new[] { MealType.Vegetarian, MealType.Indian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.50 } }, Rating = new Rating { Value = 0.6, VoteCount = 5 } }, new Meal { Name = "Pois chiches à la sauce épicée", Description = @"Raita (yogourt épicé) Riz basmati", MealTypes = new[] { MealType.Vegetarian, MealType.Indian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.50 } }, Rating = new Rating { Value = 1.0, VoteCount = 2 } }, new Meal { Name = "Émincé de poulet (CH) sauce Tikka Masala", Description = @"Dhal (lentilles) Riz basmati", MealTypes = new[] { MealType.Poultry, MealType.Indian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.50 } }, Rating = new Rating { Value = 0.66, VoteCount = 3 } } } }, new Restaurant { Name = "Cafétéria MX", Rating = new Rating { Value = 1.0, VoteCount = 2 }, Meals = new[] { new Meal { Name = "Petits filets de poulet (CH) aux champignons chinois", Description = @"Petits pois et carottes Riz au curcuma Entrée : Potage", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 12.00 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.50 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, } }, new Restaurant { Name = "Obeirut Lebanese Cuisine", Rating = new Rating { Value = 0.0, VoteCount = 0 }, Meals = new[] { new Meal { Name = "Arousse Chawarma Lahmé", Description = "Emincé de viande marinée rôtie à la broche, persil, cornichon, oignon, tomate et sauce tarator", MealTypes = new[] { MealType.Meat, MealType.Lebanese }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 7.90 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Poulet à l'Oriental", Description = "Poulet au four et sauce brune accompagnériz à la viande hachée, épices d'orient, pignons de pins, amandes et pistaches roties", MealTypes = new[] { MealType.Poultry, MealType.Lebanese }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 11.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Menu Plateau Arousse Kafta", Description = @"Brochette de viande hachée grillée assaisonnée avec du persil et oignon + Hommos, Moutabbal + Tabboulé Entrée : + Pain Libanais", MealTypes = new[] { MealType.Poultry, MealType.Lebanese }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 14.90 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } } } }, new Restaurant { Name = "Ornithorynque", Rating = new Rating { Value = 0.8, VoteCount = 100 }, Meals = new[] { new Meal { Name = "Crevettes sautées (VIE) ail et persil plat", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 10.20 }, { PriceTarget.Visitor, 12.00 }, { PriceTarget.PhDStudent, 10.20 }, { PriceTarget.Staff, 12.00 } }, Rating = new Rating { Value = 0.9, VoteCount = 5 } }, new Meal { Name = "Risotto au jambon (CH), petits pois et parmesan", Description = "", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 11.05 }, { PriceTarget.Visitor, 13.00 }, { PriceTarget.PhDStudent, 11.05 }, { PriceTarget.Staff, 13.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 2 } }, new Meal { Name = "Lasagne Verdura", Description = "Salade verte", MealTypes = new[] { MealType.Vegetarian, MealType.Pasta }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.65 }, { PriceTarget.Visitor, 9.00 }, { PriceTarget.PhDStudent, 7.65 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.8, VoteCount = 5 } }, new Meal { Name = "Pâtes sauce à l'arrabiata", Description = "Salade verte", MealTypes = new[] { MealType.Vegetarian, MealType.Pasta }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.65 }, { PriceTarget.Visitor, 9.00 }, { PriceTarget.PhDStudent, 7.65 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Tartine aux légumes du soleil", Description = @"Salade verte", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.65 }, { PriceTarget.Visitor, 9.00 }, { PriceTarget.PhDStudent, 7.65 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } } } }, new Restaurant { Name = "Le Parmentier", Rating = new Rating { Value = 0.5, VoteCount = 4 }, Meals = new[] { new Meal { Name = "Petits filets de poulet (CH) aux champignons chinois", Description = @"Petits pois et carottes Riz au curcuma", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 1 } }, new Meal { Name = "Saltimbocca de porc (CH) vénitienne", Description = @"Brocolis vapeur Pommes de terre sautées", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 12.00 }, { PriceTarget.Visitor, 12.00 }, { PriceTarget.PhDStudent, 12.00 }, { PriceTarget.Staff, 12.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "haché végétal au curry jaune et haricots coco", Description = "Salade de céleri betterave au gomasio", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 7.00 }, { PriceTarget.Visitor, 10.50 }, { PriceTarget.PhDStudent, 8.00 }, { PriceTarget.Staff, 9.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, new Meal { Name = "Omelette au gruyère et fines herbes", Description = @"Petits légumes Petits palets de roestis au four", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.Student, 9.00 }, { PriceTarget.Visitor, 12.00 }, { PriceTarget.PhDStudent, 10.00 }, { PriceTarget.Staff, 11.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 2 } } } }, new Restaurant { Name = "Le Puur Innovation", Rating = new Rating { Value = 0.0, VoteCount = 0 }, Meals = new[] { new Meal { Name = "Salade Niçoise avec thon et olives", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 12.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Gigot d'agneau (NZ) avec sauce aux échalotes et miel. Riz pilaw", Description = "", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 13.90 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Escalope de quasi de porc (CH) avec sauce au citron vert, courgettes et pommes de terre à l'origan", Description = "", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 14.90 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Pâtes fraiches maisonà la carbonara avec lardons (CH), jambon (CH), oignons et sauce au parmesan", Description = "", MealTypes = new[] { MealType.Meat, MealType.Pasta }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 13.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Pâtes fraiches maison à la Carbonara di verdura avec légumes, oignons et sauce au parmesan", Description = "", MealTypes = new[] { MealType.Vegetarian, MealType.Pasta }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 13.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Salade Caesar avec poulet (CH) pané", Description = "", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 12.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "nuggets de poulet sauce aigre douce", Description = "", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 5.90 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Salade de taboulé avec boulettes de fallafel", Description = "", MealTypes = new[] { MealType.Vegetarian }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 12.50 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } } } }, new Restaurant { Name = "La Table de Vallotton", Rating = new Rating { Value = 0.7, VoteCount = 15 }, Meals = new[] { new Meal { Name = "Tartare de thon coupé au couteau accompagné des ses toasts", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 31.00 } }, Rating = new Rating { Value = 1.0, VoteCount = 1 } }, new Meal { Name = "Mi cuit de thon, marinade minute au gingembre et riz à la coriandre", Description = "", MealTypes = new[] { MealType.Fish }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 31.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 1 } }, new Meal { Name = "Tous les midi un dessert du jour est proposé selon l'inspiration de notre chef pâtissier", Description = "", MealTypes = new[] { MealType.GreenFork }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 0.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } }, new Meal { Name = "Salade Gourmande (foie gras, gésiers et magret de canard) et pignons torréfiés", Description = "", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 10.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 1 } }, new Meal { Name = "Tartare de boeuf coupé au couteau (façcon traditionnelle ou italienne) servi avec ses toasts", Description = "", MealTypes = new[] { MealType.Meat }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 31.00 } }, Rating = new Rating { Value = 0.5, VoteCount = 1 } }, new Meal { Name = "Suprême de pintade fermière au poivre vert", Description = @"Légumes grillés Pommes à la lyonnaise", MealTypes = new[] { MealType.Poultry }, Prices = new Dictionary <PriceTarget, double> { { PriceTarget.All, 25.00 } }, Rating = new Rating { Value = 0.0, VoteCount = 0 } } } } } } )); }
public void Delete([FromBody] FoodRequest foodRequest) { //implements }
public async Task <IActionResult> PostFood([FromBody] FoodRequest request) { if (!ModelState.IsValid) { return(BadRequest(new Response { IsSuccess = false, Message = "Bad request", Result = ModelState })); } EstablishmentLocationEntity establishmentLocationEntity = await _context .EstablishmentLocations .FirstOrDefaultAsync(el => el.Id == request.EstablishmentLocationId); FoodEntity foodEntity = await _context.Foods.FirstOrDefaultAsync(f => f.FoodName == request.FoodName); TypeFoodEntity typeFoodEntity = await _context.TypeFoods.FirstOrDefaultAsync(f => f.Id == request.TypeFoodsId); UserEntity userEntity = await _userHelper.GetUserAsync(request.UserId); if (userEntity == null) { return(BadRequest("User doesn't exists.")); } if (foodEntity != null) { if (establishmentLocationEntity.Id == foodEntity.EstablishmentLocations.Id) { return(BadRequest(new Response { IsSuccess = false, Message = "This food exist in this place" })); } } string picturePath = string.Empty; if (request.PictureFoodArray != null && request.PictureFoodArray.Length > 0) { picturePath = await _blobHelper.UploadBlobAsync(request.PictureFoodArray, "foods"); } FoodEntity food = new FoodEntity { FoodName = request.FoodName, PicturePathFood = picturePath, Qualification = request.Qualification, Remarks = request.Remarks, TypeFoods = typeFoodEntity, EstablishmentLocationId = establishmentLocationEntity.Id.ToString(), EstablishmentLocations = establishmentLocationEntity, User = userEntity }; _context.Foods.Add(food); await _context.SaveChangesAsync(); return(Ok(_converterHelper.ToFoodResponse(food))); }
public void Update(FoodRequest foodRequest) { this.foodRequestRepository.Update(foodRequest); this.foodRequestRepository.SaveChanges(); }
public async Task <Response> NewFoodAsync(string urlBase, string servicePrefix, string controller, FoodRequest model, string tokenType, string accessToken) { try { string request = JsonConvert.SerializeObject(model); StringContent content = new StringContent(request, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient { BaseAddress = new Uri(urlBase) }; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(tokenType, accessToken); string url = $"{servicePrefix}{controller}"; HttpResponseMessage response = await client.PostAsync(url, content); string answer = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { return(new Response { IsSuccess = false, Message = answer, }); } FoodResponse trip = JsonConvert.DeserializeObject <FoodResponse>(answer); return(new Response { IsSuccess = true, Result = trip, }); } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message, }); } }
public async Task <Response> GetFoodAsync(string urlBase, string servicePrefix, string controller, FoodRequest model) { try { string request = JsonConvert.SerializeObject(model); StringContent content = new StringContent(request, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient { BaseAddress = new Uri(urlBase) }; string url = $"{servicePrefix}{controller}"; HttpResponseMessage response = await client.PostAsync(url, content); string answer = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { return(new Response { IsSuccess = false, Message = answer, }); } var foods = JsonConvert.DeserializeObject <List <FoodResponse> >(answer); return(new Response { IsSuccess = true, Result = foods, }); } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message, }); } }
public void Delete(FoodRequest foodRequest) { this.foodRequestRepository.Delete(foodRequest); this.foodRequestRepository.SaveChanges(); }
public Task <FoodResponse> GetMenusAsync(FoodRequest request, CancellationToken cancellationToken) { return(CallAsync <FoodRequest, CancellationToken, FoodResponse>(x => x.GetMenusAsync, request, cancellationToken)); }