public PartialViewResult GetListSimilar(string name) { var nameForRequest = name.Replace(" ", "+"); List <Similar> listSimilar = new List <Similar>(); List <SimilarViewModel> listModel = new List <SimilarViewModel>(); var listSimInDb = _similarService.GetAll().Where(a => a.ArtistId == _artistService.GetAll().FirstOrDefault(b => b.Name == name).Id); if (listSimInDb.Count() != 0) { foreach (Similar s in listSimInDb) { var modelSim = new SimilarViewModel() { Name = s.Name, Photo = s.Photo }; listModel.Add(modelSim); } return(PartialView(listModel)); } listSimilar = _similarService.GetListSimilar(nameForRequest); foreach (Similar sim in listSimilar) { sim.ArtistId = _artistService.Get(name).Id; _similarService.Create(sim); var model = new SimilarViewModel() { Name = sim.Name, Photo = sim.Photo }; listModel.Add(model); } return(PartialView(listModel)); }
public IActionResult SetNewFrameworkName(string frameworkname, string actionname) { if (actionname == "New") { var sessionNewFramework = TempData.Peek <SessionNewFramework>(); TempData.Set(sessionNewFramework); } var adminId = GetAdminId(); var sameItems = frameworkService.GetFrameworkByFrameworkName(frameworkname, adminId); var frameworks = frameworkService.GetAllFrameworks(adminId); var sortedItems = GenericSortingHelper.SortAllItems( frameworks.AsQueryable(), FrameworkSortByOptions.FrameworkName.PropertyName, BaseSearchablePageViewModel.Ascending ); var similarItems = GenericSearchHelper.SearchItems(sortedItems, frameworkname, 55, true); var brandedFrameworks = similarItems.ToList(); var matchingSearchResults = brandedFrameworks.ToList().Count; if (matchingSearchResults > 0) { var model = new SimilarViewModel() { FrameworkName = frameworkname, MatchingSearchResults = matchingSearchResults, SimilarFrameworks = brandedFrameworks, SameFrameworks = sameItems }; return(View("Developer/Similar", model)); } return(RedirectToAction("SaveNewFramework", "Frameworks", new { frameworkname, actionname })); }
public ActionResult Details(int id) { UserBehaviorDatabaseParser parser = new UserBehaviorDatabaseParser(); UserBehaviorDatabase db1 = parser.LoadUserBehaviorDatabase("/Data/NewBehavior.txt"); UserBehaviorTransformer ubt = new UserBehaviorTransformer(db1); int userid = Convert.ToInt32(Session["id"].ToString()); string email = context.login.Where(m => m.Id == userid).FirstOrDefault().Email; int realid = context.students.Where(m => m.Email == email).FirstOrDefault().Id; string name = context.students.Where(m => m.Id == realid).FirstOrDefault().FirstName; UplodedFile admin = context.ufiles.Find(id); SimilarViewModel sam = new SimilarViewModel(); sam.Description = admin.Description; sam.Id = admin.Id; sam.Name = admin.Name; sam.UpdatedFileName = admin.UpdatedFileName; sam.UplodedBy = admin.UplodedBy; sam.UplodedDate = admin.UplodedDate; sam.path = context.ufiles.Where(m => m.Id == id).FirstOrDefault().Filename; UserArticleRatingsTable ratings1; IRater rate = new LinearRater(-4, 2, 0.5, 1); ratings1 = ubt.GetUserArticleRatingsTable(rate); List <SuggestedArticlePoints> SAT = ratings1.suggestArticle(ratings1.art, id); List <UplodedFile> up = new List <UplodedFile>(); UplodedFile upa = new UplodedFile(); int i = 0; List <double> p = new List <double>(); foreach (var item in SAT) { p.Add(item.Points); upa = context.ufiles.Where(m => m.Id == item.ArticleId).FirstOrDefault(); up.Add(upa); } sam.point = p; sam.uplodedFiles = up; double a = sam.point[0]; var text = System.IO.File.ReadAllText("/Data/NewBehavior.txt"); List <string> lines = System.IO.File.ReadAllLines("/Data/NewBehavior.txt").ToList(); int index = text.IndexOf("# End"); text = text.Insert(index, "1,View," + realid + "," + name + "," + admin.Id + "," + admin.Name + Environment.NewLine); System.IO.File.WriteAllText("/Data/NewBehavior.txt", text); return(View(sam)); }