public async Task <IActionResult> tests3()
 {
     try
     {
         var recipe = _context.Recipe.Select(d => new
         {
             d.Id,
             d.Name,
             d.Calories,
             d.PrepTime,
             d.PicFilePath
         }).Where(x => x.Id == 1);
         var docs = _context.Document.Where(x => x.RefTable == "Recipe" && x.RefId == 1)
                    .Select(x => new
         {
             x.Id,
             x.FileName,
             x.FilePath,
             Url = _s3Service.GeneratePreSignedURL(x.FilePath, 2)
         });
         var res = new
         {
             recipe,
             docs
         };
         return(Ok(JsonConvert.SerializeObject(res)));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, JsonConvert.SerializeObject(new returnMsg {
             message = e.Message
         })));
     }
 }
        public async Task <IActionResult> getDietHomePage([FromQuery] int groupId)
        {
            try
            {
                var group = await _context.Group.FirstOrDefaultAsync(x => x.Id == groupId);

                var dietId = group.DieticianId;
                var user   = await _context.UserProfile.FirstOrDefaultAsync(x => x.Id == dietId);

                var PatientCount = _context.UserProfile.Where(x => x.GroupId == groupId && x.StatusId == 2).Count();
                var RequestCount = _context.UserProfile.Where(x => x.GroupId == groupId && x.StatusId == 1).Count();
                var RecipeCount  = _context.RecipeGroupRef.Where(x => x.GroupId == groupId).Count();
                var recotw       = _context.RecipeGroupRef.Where(x => x.GroupId == groupId && x.IsSpecial == true).SingleOrDefault();
                var recipe       = _context.Recipe.Select(d => new
                {
                    d.Id,
                    d.Name,
                    d.Calories,
                    d.PrepTime,
                    d.Servings,
                    steps       = d.RecipeStep.ToList(),
                    rating      = d.UserFeedback.Sum(x => x.Rating),
                    counter     = d.UserFeedback.Count(),
                    ingredients = d.RecipeIngredient.ToList()
                }).Where(q => q.Id == recotw.RecipeId).FirstOrDefault();

                var docs = _context.Document.Where(x => x.RefTable == "Recipe" && x.RefId == recotw.RecipeId)
                           .Select(x => new
                {
                    x.Id,
                    x.FileName,
                    x.FilePath,
                    Url = _s3Service.GeneratePreSignedURL(x.FilePath, 2)
                }).ToList();
                var homePage = new
                {
                    recipe.Id,
                    recipe.Name,
                    recipe.Calories,
                    recipe.PrepTime,
                    recipe.Servings,
                    Steps       = recipe.steps,
                    Ingredients = recipe.ingredients,
                    Rating      = recipe.counter > 0 ? recipe.rating / recipe.counter : 0,
                    PicFilePath = docs[0].Url,
                    group.WeeklyStatement,
                    DietFName = user.FirstName,
                    DietLName = user.LastName,
                    PatientCount,
                    RequestCount,
                    RecipeCount,
                };
                return(Ok(JsonConvert.SerializeObject(homePage)));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }