async public Task <Dictionary <ServiceDictionaryKey, object> > TryPostFavoriteFood(HttpRequest request) { Dictionary <ServiceDictionaryKey, object> dictionary = new Dictionary <ServiceDictionaryKey, object>(); int foodId = 0; int patientId = 0; try { foodId = Convert.ToInt32(request.Query["foodId"].ToString()); patientId = Convert.ToInt32(request.Query["patientId"].ToString()); } catch { dictionary.Add(ServiceDictionaryKey.ERROR, $"Bad parameters"); dictionary.Add(ServiceDictionaryKey.HTTPSTATUSCODE, HttpStatusCode.BadRequest); } try { bool succes = await _foodRepository.Favorite(patientId, foodId); if (!succes) { dictionary.Add(ServiceDictionaryKey.ERROR, $"No favorites could be performed"); dictionary.Add(ServiceDictionaryKey.HTTPSTATUSCODE, HttpStatusCode.BadRequest); return(dictionary); } else { dictionary.Add(ServiceDictionaryKey.VALUE, $"The Favorite has been added for foodid:{foodId} and patientid :{patientId}"); dictionary.Add(ServiceDictionaryKey.HTTPSTATUSCODE, HttpStatusCode.OK); } } catch (Exception ex) { dictionary.AddErrorMessage(ServiceDictionaryKey.ERROR, ex, FeedbackHandler); } return(dictionary); }