public ActionResult AllPost() { using (var _context = new ApplicationDbContext()) { var _objEntityPost = new RepositoryPattern <Post>(_context); return(View(_objEntityPost.GetAll())); } }
public ActionResult CommnetDetails() { using (var _Context = new ApplicationDbContext()) { var objPostCommnet = new RepositoryPattern <PostComment>(_Context); var AllCommnet = objPostCommnet.GetAll().OrderByDescending(x => x.SendTime).OrderByDescending(x => x.SendDate).OrderBy(x => x.Is_Read); return(View(AllCommnet)); } }
public ActionResult WebSiteVisit() { using (var _Conetxt = new ApplicationDbContext()) { var objectVisitWebSite = new RepositoryPattern <WebsiteVisit>(_Conetxt); var allVisit = objectVisitWebSite.GetAll(); return(View(allVisit)); } }
public IEnumerable <vm_AllPost> GetAllPost(string PostCount) { using (var _Context = new ApplicationDbContext()) { var _objEntityPost = new RepositoryPattern <Post>(_Context); var _post = _objEntityPost.GetAll(); //var _post = _objEntityPost.SearchFor(x => x.IsActive == "1").ToList(); var _objEntityCategory = new RepositoryPattern <Category>(_Context); var _category = _objEntityCategory.GetAll(); var _objEntityImage = new RepositoryPattern <Image>(_Context); var _image = _objEntityImage.GetAll(); var Result = new List <vm_AllPost>(); Result = (from pst in _post join im in _image on pst.ImageID equals im.ID join cat in _category on pst.CategoryID equals cat.ID //join ac in _activity //on pst.ID equals ac.Posts.ID into act //from PstAc in act.DefaultIfEmpty() select new vm_AllPost { PostID = pst.ID, Content = pst.Content, SeoMetaDescription = pst.SeoMetaDescription, LikeCount = pst.Activity.Where(x => x.ActivityTypeId == 2).Count(), //totalCount(ac.Posts.ID), Category = cat.DescriptionFa, Labels = pst.Labels, PostDate = pst.PostDate, PostTime = pst.PostTime, Title = pst.Title, ViewCount = pst.Activity.Where(x => x.ActivityTypeId == 1).Count(), ImageUrl = im.FileUrl.Substring(1), //_image.Single(x=>x.ID==pst.ImageID).FileUrl, //pst.Image.FileUrl, IsActive = pst.IsActive, CategoryID = pst.CategoryID } ).OrderByDescending(x => x.PostTime) .ThenByDescending(x => x.PostDate) .ToList(); _objEntityPost.Dispose(); _objEntityCategory.Dispose(); _objEntityImage.Dispose(); if (PostCount == "all") { return(Result); } else if (Convert.ToInt32(PostCount) > 0) { return(Result.Where(x => x.IsActive == "1").Take(Convert.ToInt32(PostCount))); } else { return(Result); } } }