示例#1
0
        public static ISeoResponse ConvertIntToResponses(List <int> positions, ISeoRequest seoRequest)
        {
            if (seoRequest == null || positions == null || positions.Count <= 0)
            {
                return(new SeoResponse()
                {
                    PositionNumbers = "0"
                });
            }
            ISeoResponse response = new SeoResponse();

            StringBuilder builder = new StringBuilder();

            foreach (int position in positions)
            {
                builder.AppendFormat("{0}, ", position);
            }
            string pos = builder.ToString();

            if (pos.EndsWith(", "))
            {
                response.PositionNumbers = pos.Remove(pos.LastIndexOf(","));
            }
            return(response);
        }
示例#2
0
        public async Task <IActionResult> GetSeo(int Skip, int Quantity)
        {
            var result = new SeoResponse();

            var seo = await _context.Seo.Skip(Skip).Take(Quantity).Select(s => new Seo {
                SeoId = s.Id, MetaTagTitle = s.MetaTagTitle
            }).ToListAsync();

            if (seo.Count == 0)
            {
                result.Code    = -100;
                result.Message = "Can't get products with given parameters.";
                return(Ok(result));
            }

            result.Code    = 100;
            result.Message = "Success";
            result.Seo     = seo;
            return(Ok(result));
        }
示例#3
0
        public async Task <IActionResult> GetSearchMethodForSeo(string Name, int Quantity)
        {
            var result = new SeoResponse();

            var seo = await _context.Seo.Take(Quantity).Where(c => c.MetaTagTitle.StartsWith(Name) || c.MetaTagTitle.Contains(Name) || c.MetaTagTitle.EndsWith(Name)).Select(p => new Seo {
                SeoId = p.Id, MetaTagTitle = p.MetaTagTitle
            }).ToListAsync();

            if (seo.Count == 0)
            {
                result.Code    = -100;
                result.Message = "Can't get products with given parameters.";
                return(Ok(result));
            }

            result.Code    = 100;
            result.Message = "Success";
            result.Seo     = seo;
            return(Ok(result));
        }
示例#4
0
        public ActionResult Analyse(SeoRequest model)
        {
            var response = new SeoResponse();

            try
            {
                var wordOccurences = model.IsUrl
                    ? SeoAnalyser.Analyse(model.Url, model.Options.Where(x => x.Selected).Select(x => x.Value).ToArray())
                    : SeoAnalyser.Analyse(model.Text);

                response.WordOccurences = wordOccurences;
                response.IsSuccess      = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess    = false;
                response.ErrorMessage = ex.Message;
            }

            return(PartialView("_AnalyseResult", response));
        }