public IActionResult Get(string name) { var authId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value; if (string.IsNullOrWhiteSpace(name)) { var fetchAll = new ResponseModel { Success = true, Message = "Found ingredients.", Data = new Data { Ingredients = _ingredientsService.Get(authId) } }; /* * var successResponse = new[] * { * fetchAll * };*/ return(Ok(new[] { fetchAll })); } else { name = name.ToLower(); List <Ingredient> ingredients = _ingredientsService.GetIngredientsByName(name); if (ingredients == null || ingredients.Count == 0) { var notFound = new ResponseModel { Success = false, Message = "Not found", Data = null, Instance = HttpContext.Request.Path }; var notFoundResponse = new[] { notFound }; return(NotFound(notFoundResponse)); } var success = new ResponseModel { Success = true, Message = "Found named ingredients.", Data = new Data { Ingredients = ingredients } }; /* * var successResponse = new [] * { * success * };*/ return(Ok(new[] { success })); } }