public DigikalaProductDTO GetFirstProductByCategory(GetFirstProductByCategoryParam param) { using (IWebsiteCrawler digikala = new DigikalaHelper()) { return(digikala.GetFirstProductByCategory <DigikalaProductDTO>(param).Result); } }
public IActionResult TopSentences(string id) { id = id.ToLower(); IWebsiteCrawler web = null; if (id == "mobile") { web = new DigikalaHelper(); } else if (id == "resturant") { web = new SnappfoodHelper(); } else { return(Ok()); } var sentences = web.GetTopSentences(); string _sentences = ""; foreach (var item in sentences) { foreach (var op in item.Opinions) { _sentences += $@"{item.Text.Replace(",", " ").Replace(" ", " ")} {op.category}_{op.aspect} {op.polarity}"+ "\r\n"; } } return(File(Encoding.UTF8.GetBytes(_sentences), "text/csv", "TopSentences.csv")); }
public string GetStatus() { using (IWebsiteCrawler digikala = new DigikalaHelper()) { return(digikala.GetSatatusReview()); } }
public List <Review> GetXml(GetFirstProductByCategoryParam param) { using (IWebsiteCrawler digikala = new DigikalaHelper()) { return(digikala.GetAllReviews1()); } }
private async static void digikala_getAllReviews_9() { List <string> reviews = new List <string>(); List <string> cleanReviews = new List <string>(); using (IWebsiteCrawler digikala = new DigikalaHelper()) { bool allReviews = true; if (true) { var digikalaReviews = digikala.GetAllReviews <string[]>(); reviews = digikalaReviews.Result.ToList(); } else { var digikalaReviews = digikala.GetAllReviews <string[]>(); reviews = digikalaReviews.Result.ToList(); int spliteSize = 50000; float size = reviews.Count / spliteSize; int itr = (int)Math.Round(size); for (int i = 0; i <= itr; i++) { string json1 = JsonConvert.SerializeObject(new Reviews { reviews = reviews.Skip(i * spliteSize).Take(spliteSize).ToList() }); File.WriteAllText(@$ "C:\Digikala\reviews\review-{i + 1}.json", json1, new UTF8Encoding(false));
public IActionResult GetAllReviews(string id) { using (IWebsiteCrawler digikala = new DigikalaHelper()) { List <Review> reviews = digikala.GetLabelReviews(); var json = JsonConvert.SerializeObject(reviews, Formatting.Indented); return(File(Encoding.UTF8.GetBytes(json), "text/json", $"AllReviews-{id}-{DateTime.Now.ToShortDateString()}.json")); } }
public AddReviewToDBResponse AddReviewNew([FromBody] AddReviewToDBParam param) { using (IWebsiteCrawler digikala = new DigikalaHelper()) { var result = digikala.AddReviewToDB_NewMethod(param); return(new AddReviewToDBResponse { Success = result }); } }
private static void digikala_6_GetProductComments() { using (IWebsiteCrawler digikala = new DigikalaHelper()) { string url1 = "https://www.digikala.com/product/dkp-313420"; string url2 = "https://www.digikala.com/product/dkp-6/"; //var cm = digikala.GetComments(url2); //var s = digikala.GetProduct<DigikalaProductDTO>(page, url2); //var jjj = JsonConvert.SerializeObject(s); } }
public IActionResult AddLabel([FromBody] AddLabelParam model) { Dictionary <string, int> pol = new Dictionary <string, int>() { { "positive", 1 }, { "neutral", 0 }, { "negative", -1 } }; if (model != null) { AddReviewToDBParam param = new AddReviewToDBParam(); param.id = model.idBson.ToString(); param.tagger = model.Tagger; ReviewDTO review = new ReviewDTO(); review._id = "000"; review.CreateDate = DateTime.Now; review.ProductID = int.Parse(model.ProductId); review.rid = int.Parse(model.ProductId); sentence sentence = new sentence(); sentence.Text = model.Text; List <Opinion> Opinions = new List <Opinion>(); if (model.AspectLabels.Count() > 0) { Opinions.AddRange(model.AspectLabels.Select(x => new Opinion { category = x.Category.ToUpper().Trim(), aspect = x.Aspect.ToUpper().Trim(), polarity = x.Polarity, polarityClass = pol[x.Polarity] }).ToList()); sentence.Opinions = Opinions; } if (Opinions.Count < 1) { sentence.OutOfScope = true; } review.sentences = new List <sentence>(); review.sentences.Add(sentence); param.review = new ReviewDTO(); param.review = review; using (IWebsiteCrawler digikala = new DigikalaHelper()) { var result = digikala.AddReviewToDB_NewMethod(param); if (!result) { return(NoContent()); } } return(Json(new { Message = "ثبت شد" })); } else { return(NoContent()); } }
private async static void digikala_5_GetProduct() { using (IWebsiteCrawler digikala = new DigikalaHelper()) { string url1 = "https://www.digikala.com/product/dkp-313420"; string url2 = "https://www.digikala.com/product/dkp-1675555"; string url3 = "https://www.digikala.com/product/dkp-676525"; string url4 = "https://www.digikala.com/product/dkp-781586"; //var page = digikala.GetPage(url2); var s = await digikala.GetProduct <DigikalaProductDTO>(url4); var jjj = JsonConvert.SerializeObject(s); } }
public IActionResult TopMobile() { IWebsiteCrawler web = new DigikalaHelper(); var sentences = web.GetTopSentences(); string _sentences = ""; foreach (var item in sentences.Where(x => !string.IsNullOrEmpty(x.Text))) { foreach (var op in item.Opinions) { _sentences += $@"{item.Text.Replace(",", " ").Replace(" ", " ")} {op.category}_{op.aspect} {op.polarity}"+ "\r\n"; } } return(File(Encoding.UTF8.GetBytes(_sentences), "text/csv", "TopSentences.csv")); }
private static void digikala_LoadSitemap() { string dirPath = @"C:\Digikala\xml\clean"; DirectoryInfo directorySelected = new DirectoryInfo(dirPath); string file1 = string.Empty; FileInfo[] fileInfos = directorySelected.GetFiles("*.xml"); List <B5_Url> dkps = new List <B5_Url>(); for (int i = 0; i < fileInfos.Length; i++) { using (var sitemap = new SitemapHelper()) { dkps.AddRange(sitemap.SitemapToObject(fileInfos[i].ToString()).urlset.ToList()); } } using (IWebsiteCrawler digikala = new DigikalaHelper()) { digikala.AddBasePages(dkps); } int sss = 5; }
private static void digikala_SaveProductBatch(ProductTemp?productTemp = null, bool force = false) { if (productTemp.HasValue) { productTemps.Add(productTemp.Value); } if (productTemps.Count() >= 20 || force) { List <ProductTemp> temp = new List <ProductTemp>(); temp.AddRange(productTemps); productTemps.Clear(); using (IWebsiteCrawler digikala2 = new DigikalaHelper()) { AddProductsDigikala addProducts = new AddProductsDigikala { digikalaProducts = temp.Select(x => x.DigikalaProduct).ToList() }; digikala2.AddProducts(addProducts); digikala2.CrawledProducts(temp.Select(x => x.BasePage.Id).ToArray()); Console.WriteLine($"{temp.Count()} Add To Database "); } } }
public IActionResult DetailsReportV3(string id = null) { List <Aspect> aspects = new List <Aspect>(); List <Category> categories = new List <Category>(); List <AspectCategory> aspectCategories = new List <AspectCategory>(); using (IWebsiteCrawler website = new DigikalaHelper()) { List <sentence> sentences = new List <sentence>(); List <Opinion> opinions = new List <Opinion>(); var data = website.GetLabelReviews(); foreach (var rev in data) { if (rev.sentences != null && rev.sentences.Count() > 0) { sentences.AddRange(rev.sentences); } } sentences.ToList(); foreach (var sentence in sentences) { if (sentence.Opinions != null && sentence.Opinions.Count() > 0) { foreach (var op in sentence.Opinions) { var q1 = aspects.Where(x => x.Name == op.aspect && x.polarity == op.polarity).Any(); if (q1) { var s = aspects.Where(x => x.Name == op.aspect && x.polarity == op.polarity).FirstOrDefault(); s.count += 1; } else { aspects.Add(new Aspect { Name = op.aspect, count = 1, polarity = op.polarity }); } var q2 = categories.Where(x => x.Name == op.category && x.polarity == op.polarity).Any(); if (q2) { var s1 = categories.Where(x => x.Name == op.category && x.polarity == op.polarity).FirstOrDefault(); s1.count += 1; } else { categories.Add(new Category { Name = op.category, count = 1, polarity = op.polarity }); } var q3 = aspectCategories.Where(x => x.aspect == op.aspect && x.category == op.category && x.polarity == op.polarity).Any(); if (q3) { var s2 = aspectCategories.Where(x => x.aspect == op.aspect && x.category == op.category && x.polarity == op.polarity).FirstOrDefault(); s2.count += 1; } else { aspectCategories.Add(new AspectCategory { category = op.category, aspect = op.aspect, count = 1, polarity = op.polarity }); } opinions.Add(op); } } } opinions.ToList(); string aspp = ""; foreach (var item in aspects) { aspp += $"{item.Name} {item.polarity} {item.count}\n"; } string cats = ""; foreach (var item in categories) { cats += $"{item.Name} {item.polarity} {item.count}\n"; } string aspectCats = ""; foreach (var item in aspectCategories) { aspectCats += $"{item.category} {item.aspect} {item.polarity} {item.count}\n"; } var Cats = aspectCategories.Select(x => x.category).Distinct().ToArray(); var Aspects = aspectCategories.Select(x => x.aspect).Distinct().ToArray(); string[,] table = new string[Cats.Length + 1, Aspects.Length + 1]; table[0, 0] = "X"; for (int j = 1; j < Aspects.Length + 1; j++) { table[0, j] = Aspects[j - 1]; } for (int i = 1; i < Cats.Length + 1; i++) { table[i, 0] = Cats[i - 1]; } for (int i = 1; i < Cats.Length + 1; i++) { for (int j = 1; j < Aspects.Length + 1; j++) { var catAspc = aspectCategories.Where(x => x.aspect.Contains(Aspects[j - 1]) && x.category.Contains(Cats[i - 1])).ToList(); var polPlus = catAspc.Count() > 0 && catAspc.Where(x => x.polarity == "positive").Any() ? catAspc.Where(x => x.polarity == "positive").FirstOrDefault().count : 0; int polNet = catAspc.Count() > 0 && catAspc.Where(x => x.polarity == "neutral").Any() ? catAspc.Where(x => x.polarity == "neutral").FirstOrDefault().count : 0; int polNeg = catAspc.Count() > 0 && catAspc.Where(x => x.polarity == "negative").Any() ? catAspc.Where(x => x.polarity == "negative").FirstOrDefault().count : 0; if (polPlus == 0 && polNet == 0 && polNeg == 0) { table[i, j] = "-"; } else { table[i, j] = $"{polPlus},{polNet},{polNeg}"; } } } string tabl = ""; for (int i = 0; i < Cats.Length + 1; i++) { for (int j = 0; j < Aspects.Length + 1; j++) { tabl += table[i, j] + "\t"; } tabl += "\n"; } return(Ok(tabl)); } }
public IActionResult DetailsReportV2(string id = null) { if (id == "digi") { using (IWebsiteCrawler snapp = new DigikalaHelper()) { //var jhkkj = digikala.GetAllReviews1(); List <sentence> sentences = new List <sentence>(); List <sentence> sentencesTrain = new List <sentence>(); List <sentence> sentencesTest = new List <sentence>(); List <sentence> sentencesTest1 = new List <sentence>(); var data = snapp.GetLabelReviews(); foreach (var rev in data) { if (rev.sentences != null && rev.sentences.Count() > 0) { sentences.AddRange(rev.sentences); } } sentences.ToList(); int countTest = (int)(sentences.Count() * 0.2); int countTrain = sentences.Count() - countTest; sentencesTrain = sentences.Take(countTrain).ToList(); sentencesTest = sentences.Skip(countTrain).Take(countTest).ToList(); sentencesTest1 = sentencesTest.Select(x => new sentence { id = x.id, Opinions = new List <Opinion> { x.Opinions.First() }, OutOfScope = x.OutOfScope, Text = x.Text }).ToList(); string result = "Result:"; result += "\n\n****************************************\n❌ All Data:\n\n\n" + getDetails(sentences); result += "\n\n****************************************\n❌ 1.Tarin:\n\n\n" + getDetails(sentencesTrain); result += "\n\n****************************************\n❌ 2.Test:\n\n\n" + getDetails(sentencesTest); result += "\n\n****************************************\n❌ 3.Test First:\n\n\n" + getDetails(sentencesTest1); return(Ok(result)); } } using (IWebsiteCrawler snapp = new SnappfoodHelper()) { //var jhkkj = digikala.GetAllReviews1(); List <sentence> sentences = new List <sentence>(); List <sentence> sentencesTrain = new List <sentence>(); List <sentence> sentencesTest = new List <sentence>(); List <sentence> sentencesTest1 = new List <sentence>(); var data = snapp.GetLabelReviews(); foreach (var rev in data) { if (rev.sentences != null && rev.sentences.Count() > 0) { sentences.AddRange(rev.sentences); } } sentences.ToList(); int countTest = (int)(sentences.Count() * 0.2); int countTrain = sentences.Count() - countTest; sentencesTrain = sentences.Take(countTrain).ToList(); sentencesTest = sentences.Skip(countTrain).Take(countTest).ToList(); sentencesTest1 = sentencesTest.Select(x => new sentence { id = x.id, Opinions = new List <Opinion> { x.Opinions.First() }, OutOfScope = x.OutOfScope, Text = x.Text }).ToList(); string result = "Result:"; result += "\n\n****************************************\n❌ All Data:\n\n\n" + getDetails(sentences); result += "\n\n****************************************\n❌ 1.Tarin:\n\n\n" + getDetails(sentencesTrain); result += "\n\n****************************************\n❌ 2.Test:\n\n\n" + getDetails(sentencesTest); result += "\n\n****************************************\n❌ 3.Test First:\n\n\n" + getDetails(sentencesTest1); return(Ok(result)); } }
public IActionResult Label(string id) { //Aspects aspects = new Aspects(); List <User> users = new List <User>(); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "اپل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "سامسونگ" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "اپل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "هوآوی" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "شیائومی" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Role = "admin" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "سامسونگ" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "اپل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "هوآوی" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "شیائومی" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); if (!string.IsNullOrEmpty(id)) { User _user = users.Where(x => x.Username.ToLower() == id.ToLower().Trim() ).FirstOrDefault(); if (_user != null) { TaggerVM tagger = new TaggerVM(); tagger.User = _user; tagger.Tagger = _user.Username; using (IWebsiteCrawler digikala = new DigikalaHelper()) { GetFirstProductByCategoryParam param = new GetFirstProductByCategoryParam(); param.Brand = _user.Brand; param.category = _user.Category; param.tagger = _user.Username; param.title = _user.Title; var s = digikala.GetFirstProductByCategory <DigikalaProductDTO>(param).Result; tagger.ProductCount = s.Comments.Count(); List <CommentDTO> comments = new List <CommentDTO>(); using (var html = new HtmlHelper()) { foreach (var item in s.Comments) { CommentDTO comment = new CommentDTO(); comment = item; var _cm = html.CleanReview(item.Review); if (!string.IsNullOrEmpty(_cm)) { comment.Review = _cm.Replace(". ", "\n"); } comments.Add(comment); } } tagger.CommentJson = JsonConvert.SerializeObject(comments); tagger.CommentTitle = s.Comments.FirstOrDefault().Title; tagger.CountReview = s.Comments.Count(); tagger.CountCurrent = 0; tagger.Review = s.Comments.FirstOrDefault().Review; tagger.ProductId = s.DKP; tagger.idBson = s._id; tagger.ProductName = s.Title; //tagger.ProductDTO = s; } return(View(tagger)); } } return(Redirect("http://google.com")); }
private async static void digikala_7_AddProductToMongo() { for (short i = 0; i < 120; i++) { List <DigikalaPageBaseDTO> getAll = new List <DigikalaPageBaseDTO>(); List <BasePage> pages = new List <BasePage>(); using (IWebsiteCrawler digikala = new DigikalaHelper()) { getAll = (await digikala.GetAllBasePage <GetAllBasePageDigikalaResult>()).BasePages; Console.WriteLine($"list total {getAll.Count()}"); pages = getAll.Select(x => new BasePage { Id = x._id, Loc = x.Loc }).ToList(); getAll.Clear(); } long x = 0; short errorCount = 0; foreach (var item in pages) { try { var _s = DateTime.Now; DigikalaProductDTO product = null; using (IWebsiteCrawler digikala = new DigikalaHelper()) { product = await digikala.GetProduct <DigikalaProductDTO>(item.Loc); } if (product == null) { int dkp = getDKPWithUrl(item.Loc); Console.WriteLine($"Try Again , DKP - {dkp} Wait: {1000} Secs"); System.Threading.Thread.Sleep(1000 * errorCount); using (IWebsiteCrawler digikala = new DigikalaHelper()) { product = await digikala.GetProduct <DigikalaProductDTO>(item.Loc); } } var _t = Math.Round((DateTime.Now - _s).TotalSeconds, 2); if (product != null) { ProductTemp prd = new ProductTemp(); prd.BasePage = item; prd.DigikalaProduct = product; digikala_SaveProductBatch(prd); Console.WriteLine($"S{i}, {++x} = DKP-{product.DKP} , Comment={(product.Comments != null ? product.Comments.Count() + "+ " : "0 ")} , in {_t} Secs "); if (x % 5 == 0) { Console.WriteLine("--------------"); System.Threading.Thread.Sleep(100); } if (x % 100 == 0) { System.Threading.Thread.Sleep(500); Console.Clear(); } errorCount = 0; } else { if (errorCount < 3) { errorCount += 1; } int dkp = getDKPWithUrl(item.Loc); Console.WriteLine($"{++x} = DKP-{dkp} , Wait: {1000 * errorCount} Secs , *** Error *** ,"); System.Threading.Thread.Sleep(1000 * errorCount); } } catch (Exception ex) { if (errorCount < 3) { errorCount += 1; } int dkp = getDKPWithUrl(item.Loc); Console.WriteLine($"{++x} = DKP-{dkp} , Wait: {1000 * errorCount} Secs , *** Error *** Problem"); using (ILoger Logger = new MongoDBLoggerHelper()) { LogDTO log = new LogDTO() { _id = ObjectId.GenerateNewId().ToString(), DateTime = DateTime.Now, Description = ex.Message.ToString(), ProjectId = (int)ProjectNames.Console, Url = item.Loc, MethodName = "Digikala - Console App", Title = "Get Product Error - " + dkp }; Logger.AddLog(log); } System.Threading.Thread.Sleep(1000 * errorCount); } } } digikala_SaveProductBatch(null, true); }
private void btnNext_Click(object sender, RoutedEventArgs e) { if (opinions != null && opinions.Count() > 0 && !string.IsNullOrEmpty(txtSelectReview.Text)) { sentences.Add(new sentence { id = sentenceId, Text = txtSelectReview.Text.Trim(), Opinions = opinions }); opinions.Clear(); } using (IWebsiteCrawler digikala = new DigikalaHelper()) { if (sentences != null && sentences.Count() > 0) { if (review.sentences == null) { review.sentences = new List <sentence>(); } review.sentences.AddRange(sentences); sentences.Clear(); } if (review != null && review.sentences != null && review.sentences.Count() > 0) { review.CreateDate = DateTime.Now; //review._id = ObjectId.GenerateNewId(DateTime.Now); review.rid = digikalaProduct.DKP; AddReviewToDBParam param = new AddReviewToDBParam { review = review, id = digikalaProduct._id, tagger = user.Username }; AddReviewToDBResponse resultAddReview = new AddReviewToDBResponse() { Success = false }; //bool resultAddReview = digikala.AddReviewToDB(param); // ☺ Api using (var Api = new WebAppApiCall()) { resultAddReview = Api.GetFromApi <AddReviewToDBResponse>("AddReviewtodb", param); } if (resultAddReview.Success) { sentences.Clear(); sentenceIdReset(); review = new ReviewDTO(); } else { MessageBox.Show("ثبت با مشکل روبرو شده است دوباره سعی کنید.", "Warning"); return; } } GetFirstProductByCategoryParam getProductParam = new GetFirstProductByCategoryParam { category = user.Category, title = user.Title, Brand = user.Brand, tagger = user.Username }; // ☺ Api using (var Api = new WebAppApiCall()) { digikalaProduct = Api.GetFromApi <DigikalaProductDTO>("GetFirstProductByCategory", getProductParam); } //digikalaProduct = digikala.GetFirstProductByCategory<DigikalaProductDTO>(getProductParam).Result; commentCurrentIndex = -1; commentCount = digikalaProduct.Comments.Count(); nextReview(); txtProductId.Text = digikalaProduct.DKP.ToString(); txtTitle.Text = digikalaProduct.Title; txtEnTitle.Text = digikalaProduct.TitleEN; review.ProductID = digikalaProduct.DKP; } }
private void btnAddSentence_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtSelectReview.Text)) { sentence sentence = new sentence(); if (opinions != null && opinions.Count() > 0) { var _opinions = opinions.Select(x => new Opinion { category = x.category, aspect = x.aspect, polarity = x.polarity, polarityClass = x.polarityClass }).ToList(); sentence = new sentence() { id = sentenceId, Text = txtSelectReview.Text.Trim(), Opinions = _opinions }; } if (opinions == null || opinions.Count() == 0) { sentence = new sentence() { id = sentenceId, Text = txtSelectReview.Text.Trim(), Opinions = new List <Opinion>(), OutOfScope = true }; } sentences.Add(sentence); var sen = sentences.ToList(); if (sentences != null && sentences.Count() > 0) { if (review.sentences == null) { review.sentences = new List <sentence>(); } review.sentences.AddRange(sentences); sentences.Clear(); } using (IWebsiteCrawler digikala = new DigikalaHelper()) { try { if (review != null && review.sentences != null && review.sentences.Count() > 0) { review.CreateDate = DateTime.Now; //review._id = ObjectId.GenerateNewId(DateTime.Now); review.rid = digikalaProduct.DKP; AddReviewToDBParam param = new AddReviewToDBParam { review = review, id = digikalaProduct._id, tagger = user.Username }; AddReviewToDBResponse resultAddReview = new AddReviewToDBResponse() { Success = false }; //bool resultAddReview = digikala.AddReviewToDB(param); // ☺ Api using (var Api = new WebAppApiCall()) { resultAddReview = Api.GetFromApi <AddReviewToDBResponse>("AddReviewNew", param); } if (resultAddReview.Success) { sentences.Clear(); sentenceIdReset(); } else { MessageBox.Show("ثبت با مشکل روبرو شده است دوباره سعی کنید. _ دوباره سعی کن نشد به بهزاد بگو", "Warning"); return; } } } catch (Exception) { MessageBox.Show("خطا در ارسال اطلاعات به سرور ، لطفا به بهزاد خبر دهید که برنامه کار نمیکنه !!!"); } } txtReview.Text = txtReview.Text.Replace(txtSelectReview.Text.Trim(), "").Trim(); txtSelectReview.Text = ""; } fillAspects(); listAspects.Items.Clear(); opinions.Clear(); }
public IActionResult Privacy(string id) { List <User> users = new List <User>(); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Role = "admin" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل", Brand = "اپل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); users.Add(new User { Username = "******", Password = "******", Category = "گوشی موبایل" }); if (!string.IsNullOrEmpty(id)) { User _user = users.Where(x => x.Username.ToLower() == id.ToLower().Trim() ).FirstOrDefault(); if (_user != null) { TaggerVM tagger = new TaggerVM(); tagger.User = _user; tagger.Tagger = _user.Username; using (IWebsiteCrawler digikala = new DigikalaHelper()) { GetFirstProductByCategoryParam param = new GetFirstProductByCategoryParam(); param.Brand = _user.Brand; param.category = _user.Category; param.tagger = _user.Username; //param.title = _user.Title; var s = digikala.GetFirstProductByCategory <DigikalaProductDTO>(param).Result; tagger.ProductCount = s.Comments.Count(); tagger.CommentJson = JsonConvert.SerializeObject(s.Comments); tagger.CommentTitle = s.Comments.FirstOrDefault().Title; } return(View(tagger)); } } return(Redirect("http://google.com")); }