public List <CommentViewModel> Search(CommentSearchModel searchModel) { var query = _context.Comments .Select(x => new CommentViewModel { Id = x.Id, Name = x.Name, Email = x.Email, Website = x.Website, Message = x.Message, OwnerRecordId = x.OwnerRecordId, Type = x.Type, IsCanceled = x.IsCanceled, IsConfirmed = x.IsConfirmed, CommentDate = x.CreationDate.ToFarsi() }); if (!string.IsNullOrWhiteSpace(searchModel.Name)) { query = query.Where(x => x.Name.Contains(searchModel.Name)); } if (!string.IsNullOrWhiteSpace(searchModel.Email)) { query = query.Where(x => x.Email.Contains(searchModel.Email)); } return(query.OrderByDescending(x => x.Id).ToList()); }
public PageSearchResult <CommentViewInfo> CommentSearchResult(CommentSearchModel search) { // string sql = string.Format(@"select cm.JokeId,cm.ID as CommentId,cm.Content as Comment,cm.UserID,us.UserName,cm.Floor from T_Comment cm // inner join T_Joke jk on cm.JokeId = jk.ID // inner join T_User us on us.id=cm.UserID where cm.JokeId={0}",search.JokeID); string sql = string.Format(@"declare @@pagenum int ={1}; declare @@pagesize int = {2}; with tmp as( select ROW_NUMBER() OVER(ORDER by cm.ID desc) as Num, cm.JokeId,cm.ID as CommentId,cm.Content as Comment,cm.UserID,us.UserName,cm.Floor from T_Comment cm inner join T_Joke jk on cm.JokeId = jk.ID inner join T_User us on us.id=cm.UserID where cm.JokeId={0}) select JokeId,CommentId,Comment,UserID,UserName,UserName,Floor from tmp where Num>(@@pagenum-1)*@@pagesize and Num<=@@pagenum*@@pagesize; select count(1) from T_Comment with(nolock) where JokeId={0}", search.JokeID, search.Page, search.PageSize); var items = this.jokeDatabase.FetchMultiple <CommentViewInfo, int>(sql, search.Page, search.PageSize); var pageResult = new PageSearchResult <CommentViewInfo>() { Items = items.Item1, Page = search.Page, PageSize = search.PageSize, TotalCount = items.Item2[0] }; return(pageResult); }
public List <CommentViewModel> Search(CommentSearchModel searchModel) { var query = _shopContext.Comments.Include(c => c.Product) .Select(c => new CommentViewModel() { Id = c.Id, ProductId = c.ProductId, Name = c.Name, Email = c.Email, Message = c.Message, Product = c.Product.Name, IsConfirmed = c.IsConfirmed, IsCanceled = c.IsCanceled, CreationDate = c.CreationDate.ToFarsi() }).AsNoTracking(); if (searchModel.ProductId != 0) { query = query.Where(c => c.ProductId == searchModel.ProductId); } if (!string.IsNullOrWhiteSpace(searchModel.Name)) { query = query.Where(c => c.Name.Contains(searchModel.Name)); } if (!string.IsNullOrWhiteSpace(searchModel.Email)) { query = query.Where(c => c.Name.Contains(searchModel.Email)); } return(query.OrderByDescending(c => c.Id).ToList()); }
public ActionResult CommentSearch(int EventId) { Event newEvent = new Event(); newEvent = db.EventDb.Where(x => x.Id == EventId).FirstOrDefault(); NFLGameSchedule game = new NFLGameSchedule(); game = db.NFLGameSchedulesDb.Where(x => x.Id == newEvent.NFLGameScheduleId).FirstOrDefault(); string[] weather = NFL_API.GET_NFL.GetWeather(game.homeTeam); CommentSearchModel model = new CommentSearchModel() { EventId = EventId }; var PeopleComments = db.Comments.Where(y => y.EventId == model.EventId).ToList(); PeopleComments.Reverse(); model.List_Commments = PeopleComments; foreach (var item in PeopleComments) { var userId = db.Comments.FirstOrDefault(a => a.Comments == item.Comments); User commentUser = db.UserProfile.FirstOrDefault(b => b.Id == userId.UserId); model.UserName = commentUser.UserName; } Event eventDetail = db.EventDb.FirstOrDefault(y => y.Id == model.EventId); model.EventTitle = eventDetail.EventTitle; NFLGameSchedule eventSchedule = db.NFLGameSchedulesDb.FirstOrDefault(z => z.Id == eventDetail.NFLGameScheduleId); model.gameDate = eventSchedule.gameDate; model.gameWeek = eventSchedule.gameWeek; model.gameTimeET = eventSchedule.gameTimeET; model.homeTeam = eventSchedule.homeTeam; model.awayTeam = eventSchedule.awayTeam; model.EventComments = eventDetail.EventComments; model.stadium = weather[8]; model.isDome = weather[9]; model.geoLat = weather[10]; model.geoLong = weather[11]; model.low = weather[12]; model.high = weather[13]; model.forecast = weather[14]; model.windChill = weather[15]; model.windSpeed = weather[16]; model.domeImg = weather[17]; model.smallImg = weather[18]; model.mediumImg = weather[19]; model.largeImg = weather[20]; return(View(model)); }
public ActionResult CommentSearch(CommentSearchModel model) { //var PeopleComments = db.Comments.Where(y => y.EventId == model.EventId).ToList(); //model.List_Commments = PeopleComments; var userId = User.Identity.GetUserId(); User currentUser = db.UserProfile.FirstOrDefault(x => x.LoginId == userId); //model.UserName = currentUser.UserName; //Event eventDetail = db.EventDb.FirstOrDefault(y => y.Id == model.EventId); //model.EventTitle = eventDetail.EventTitle; var comment = new Comment { UserId = db.UserProfile.Where(x => x.LoginId == userId).FirstOrDefault().Id, EventId = model.EventId, Comments = model.CommentString }; db.Comments.Add(comment); db.SaveChanges(); return(CommentSearch(model.EventId)); }
public JsonResult SearchComments([FromBody] CommentSearchModel searchModel) { try { var response = _context.Comment.AsQueryable(); // Get all the propertyInfo of searchModel PropertyInfo[] propInfo = searchModel.GetType().GetProperties(); foreach (var prop in propInfo) { if (prop.GetValue(searchModel) != null) { // Generate query string query = ""; if (prop.PropertyType == typeof(string)) { // String type query query = string.Format("{0}.Contains(@0)", prop.Name.ToString()); } else { // Number Type query query = string.Format("{0} == @0", prop.Name.ToString()); } // Get Value base on this property var searchValue = prop.GetValue(searchModel).ToString(); // execute response = response.Where(query, searchValue); } } return(Json(response.ToList())); } catch (Exception ex) { return(Json(new { result = "ERROR", message = ex.Message })); } }
public IQueryable <Comment> BulidCommentQuery(IQueryable <Comment> query, CommentSearchModel model) { if (!string.IsNullOrEmpty(model.Search)) { query = query.Where(c => c.Author.Contains(model.Search) || c.Content.Contains(model.Search)); } if (!string.IsNullOrEmpty(model.IpAddress)) { query = query.Where(c => c.AuthorIP == model.IpAddress); } if (model.Status == null) { query = query.Where(c => c.Status == CommentStatus.Open || c.Status == CommentStatus.Verify); } else { query = query.Where(c => c.Status == model.Status); } return(query); }
public List <CommentViewModel> Search(CommentSearchModel searchModel) { return(_commentRepository.Search(searchModel)); }
public ActionResult Index(CommentSearchModel model, string message = null, string method = null, int[] commentIds = null) { if (method != null) { if (method.Equals("Trash")) { return(TrashList(commentIds)); } else if (method.Equals("Delete")) { return(DeleteList(commentIds)); } else if (method.Equals("UnTrash")) { return(UnTrashList(commentIds)); } } ViewBag.Message = message; int pageSize = int.Parse(_settingService.GetSetting("AdminCommentPageSize")); if (model.PageSize != null && model.PageSize > 0 && model.PageSize != pageSize) { _settingService.SetSetting("AdminCommentPageSize", model.PageSize.ToString()); } else { model.PageSize = pageSize; } PageInfo <Comment> pageInfo = new PageInfo <Comment>(); int count = (int)_commentService.Single(query => BulidCommentQuery(query, model).Count()); pageInfo.TotalItem = count; pageInfo.PageSize = model.PageSize.Value; model.PageIndex = model.PageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : model.PageIndex; model.PageIndex = model.PageIndex < 1 ? 1 : model.PageIndex; IList <Comment> list = _commentService.Find(query => BulidCommentQuery(query, model).OrderByDescending(c => c.CreateDate).Skip((model.PageIndex - 1) * model.PageSize.Value).Take(model.PageSize.Value)); pageInfo.PageItems = list; model.PageInfo = pageInfo; model.AllCount = (int)_commentService.Single(query => query.Where(c => (c.Status == CommentStatus.Open) || (c.Status == CommentStatus.Verify)).Count()); model.OpenCount = (int)_commentService.Single(query => query.Where(c => (c.Status == CommentStatus.Open)).Count()); model.VerifyCount = (int)_commentService.Single(query => query.Where(c => (c.Status == CommentStatus.Verify)).Count()); model.DeleteCount = (int)_commentService.Single(query => query.Where(c => (c.Status == CommentStatus.Delete)).Count()); IDictionary <int, int> VerifyComment = new Dictionary <int, int>(); foreach (Comment comment in model.PageInfo) { if (!VerifyComment.ContainsKey(comment.Article.ArticleId)) { VerifyComment[comment.Article.ArticleId] = (int)_commentService.GetCommentSingle(query => query.Where(c => c.Article.Type == ArticleType.Blog && c.Article.ArticleId == comment.Article.ArticleId && c.Status == CommentStatus.Verify).Count()); } } ViewBag.VerifyComment = VerifyComment; return(View(model)); }
public void OnGet(CommentSearchModel searchModel) { Comments = _commentApplication.Search(searchModel); }
public ActionResult CommentList(CommentSearchModel search) { var items = jokeBusinessLogic.CommentSearchResult(search); return(View(items)); }
public PageSearchResult <CommentViewInfo> CommentSearchResult(CommentSearchModel search) { var items = commentData.CommentSearchResult(search); return(items); }
public void OnGet(CommentSearchModel searchModel) { Comments = _commentApplication.Search(searchModel); Products = new SelectList(_productApplication.GetProducts(), "Id", "Name"); }