private void LoadBookmark(ApplicationUser user) { AD AD = new AD(); Target response_bookmarks = new Target(ResponseBookmarks); foreach (var item in user.Bookmarks) { string SID = item.SID; AD.SearchAll(SID, response_bookmarks); } }
public void Search(string query) { AD AD = new AD(); Target response = new Target(Response); AD.SearchAll(query, response); Clients.Caller.searchend(); }
public void Setbookmark(string SID) { //HttpCookie cookie = new HttpCookie("favorite", SID); //HttpContext.Current.Response.Cookies.Add(cookie); var userName = Context.User.Identity.Name; var _userManager = Context.Request.GetHttpContext().GetOwinContext().GetUserManager<ApplicationUserManager>(); //var _userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>(); var user = _userManager.FindByName(userName); Bookmark _bookmark = user.Bookmarks.FirstOrDefault<Bookmark>(x => x.SID == SID); if (_bookmark == null) { Bookmark bookmark = new Bookmark(); bookmark.SID = SID; bookmark.User = user; bookmark.UserId = user.Id; user.Bookmarks.Add(bookmark); AD AD = new AD(); Target response_bookmarks = new Target(ResponseBookmarks); AD.SearchAll(SID, response_bookmarks); _userManager.Update(user); } else { ApplicationDbContext db = new ApplicationDbContext(); Bookmark book = db.Bookmarks.Single(x => x.SID == SID & x.UserId == user.Id); db.Bookmarks.Remove(book); db.SaveChanges(); Clients.Caller.response_bookmarks_del(_bookmark.SID); } }