public IActionResult DeleteContent(LanguageAndProductDTO languageAndProductDTO)
        {
            var apiJsonResponse = new ApiJsonResponse();

            try
            {
                using (FoodInfoServiceContext context = new FoodInfoServiceContext())
                {
                    var product = context.ProductContents.Where(x => x.Product.BarcodeId == languageAndProductDTO.BarcodeId && x.Language.LanguageCode == languageAndProductDTO.LanguageCode && x.IsDeleted == false).FirstOrDefault();
                    if (product == null)
                    {
                        return(apiJsonResponse.ApiBadRequestWithMessage(PublicConstants.ProductDoesNotFound));
                    }
                    product.IsDeleted = true;

                    context.SaveChanges();
                    return(apiJsonResponse.ApiOkContentResult(languageAndProductDTO));
                }
            }
            catch (Exception ex)
            {
                return(apiJsonResponse.ApiBadRequestWithMessage(PublicConstants.SysErrorMessage));
            }
        }
        public IActionResult GetProductContentByLanguageCode(LanguageAndProductDTO languageAndProductDTO)
        {
            var apiJsonResponse = new ApiJsonResponse();

            try
            {
                using (FoodInfoServiceContext context = new FoodInfoServiceContext())
                {
                    if (languageAndProductDTO.LanguageCode != null)
                    {
                        if (context.Products.Any(x => x.BarcodeId == languageAndProductDTO.BarcodeId))
                        {
                            if (context.ProductContents.Any(x => x.Language.LanguageCode == languageAndProductDTO.LanguageCode && x.IsDeleted == false && x.Product.BarcodeId == languageAndProductDTO.BarcodeId))
                            {
                                var product = context.ProductContents.Where(x => x.Product.BarcodeId == languageAndProductDTO.BarcodeId &&
                                                                            x.Language.LanguageCode == languageAndProductDTO.LanguageCode &&
                                                                            x.IsDeleted == false)
                                              .Include(m => m.NutritionFact)
                                              .Include(m => m.Product).FirstOrDefault();
                                ContentDTO contentDTO = Mapper.Map <ContentDTO>(product);
                                try
                                {
                                    var comments = context.Comments.Where(x => x.ProductContent.ID == product.ID && x.IsDeleted == false).ToList();

                                    if (comments != null)
                                    {
                                        List <CommentDTO> commentDTOs = new List <CommentDTO>();
                                        // contentDTO.Comments = Mapper.Map<List<CommentDTO>>(comments);
                                        int i = 0;
                                        foreach (var item in comments)
                                        {
                                            var commentDTO = new CommentDTO();
                                            var temp       = context.User.Where(x => x.ID == item.CreatedUserId).FirstOrDefault();
                                            commentDTO.CreatedDate      = item.CreatedDate;
                                            commentDTO.CreatedUserId    = item.CreatedUserId;
                                            commentDTO.Name             = temp.Name;
                                            commentDTO.Surname          = temp.Surname;
                                            commentDTO.Username         = temp.Username;
                                            commentDTO.UserComment      = item.UserComment;
                                            commentDTO.ProductContentId = item.ProductContent.ID;
                                            commentDTO.ModifiedDate     = item.ModifiedDate;
                                            commentDTO.ModifiedUserId   = item.ModifiedUserId;



                                            commentDTOs.Add(commentDTO);
                                        }

                                        contentDTO.Comments = commentDTOs;
                                    }
                                }
                                catch
                                {
                                }


                                int totalVotes = context.Votes.Count(x => x.Product.BarcodeId == languageAndProductDTO.BarcodeId);
                                if (totalVotes == 0)
                                {
                                    contentDTO.AverageVote = 5.0M;
                                }
                                else
                                {
                                    int count = 0;
                                    foreach (var item in context.Votes.Where(x => x.Product.BarcodeId == languageAndProductDTO.BarcodeId))
                                    {
                                        if (item.UserVote != null)
                                        {
                                            count += (int)item.UserVote;
                                        }
                                    }
                                    if (count != 0)
                                    {
                                        contentDTO.AverageVote = decimal.Round((count / (decimal)totalVotes), 2);
                                    }
                                    else
                                    {
                                        contentDTO.AverageVote = 5.0M;
                                    }
                                }


                                return(apiJsonResponse.ApiOkContentResult(contentDTO));
                            }
                            else
                            {
                                return(apiJsonResponse.ApiBadRequestWithMessage(PublicConstants.BarcodeIdOrLanguageCodeDoesNotFound));
                            }
                        }
                        else
                        {
                            return(apiJsonResponse.ApiBadRequestWithMessage(PublicConstants.ProductDoesNotFound));
                        }
                    }
                    else
                    {
                        return(apiJsonResponse.ApiBadRequestWithMessage(PublicConstants.ProvideLanguageCode));
                    }
                }
            }
            catch (Exception ex)
            {
                return(apiJsonResponse.ApiBadRequestWithMessage(PublicConstants.SysErrorMessage));
            }
        }