public async Task <ApiResult <string> > UpdatePrioritizeRecipe(UpdatePrioritizeRecipe bundle) { var json = JsonConvert.SerializeObject(bundle); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"/api/recipe/prioritize"; var result = await Update <string>(url, httpContent); return(result); }
public async Task <IActionResult> Update([FromBody] UpdatePrioritizeRecipe bundle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _recipeService.UpdatePrioritizeRecipe(bundle); if (!result.IsSuccessed) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <ApiResult <string> > UpdatePrioritizeRecipe(UpdatePrioritizeRecipe bundle) { var reciper = await _context.Recipes .FirstAsync(x => x.IdProduct == bundle.IdProduct && x.Prioritize == true); reciper.Prioritize = false; _context.Recipes.Update(reciper); var prioritize = await _context.Recipes.FirstAsync(x => x.Id == bundle.Id); prioritize.Prioritize = true; _context.Recipes.Update(prioritize); await _context.SaveChangesAsync(); return(new ApiSuccessResult <string>(prioritize.Name)); }
public async Task <IActionResult> UpdatePrioritizeRecipe(UpdatePrioritizeRecipe bundle) { var result = await _recipeApiClient.UpdatePrioritizeRecipe(bundle); return(Ok(result)); }