private List <ExtendentComments> AuctionList_GetData() { //returns list of comments connected to user CommentsContext commentsContext = new CommentsContext(); string ID = HttpContext.Current.User.Identity.GetUserId(); List <Auction> assAuctionList = GetListOfAssAuctions(ID, commentsContext).ToList(); List <ExtendentComments> extendentCommentsList = new List <ExtendentComments>(); foreach (Auction item in assAuctionList) { ExtendentComments row = new ExtendentComments() { AuctionTitle = item.Title, AuctionUrl = "AuctionDetails.aspx?Id=" + item.Id, SellerUrl = "CommentSite.aspx?Id=" + item.CreatorId, SellerName = ExtensionMethods.GetUserNameByID(item.CreatorId), }; if (item.IsEnded) { row.Id = ExtensionMethods.GetCommentFromAuction(item.Id, ID, commentsContext).Id; row.Rate = ExtensionMethods.GetCommentFromAuction(item.Id, ID, commentsContext).Rate; row.Comment = ExtensionMethods.GetCommentFromAuction(item.Id, ID, commentsContext).Description; } extendentCommentsList.Add(row); } return(extendentCommentsList); }
public static CommentsContext Create(ParseInput input) { var instance = new CommentsContext(input); instance.Init(); return(instance); }
/// <summary> /// Сохраняет в БД /// </summary> /// <param name="comments"></param> public static void Save(Comments comments) { using (var db = new CommentsContext()) { db.Comments.Add(comments); db.SaveChanges(); } }
private IQueryable <Auction> GetListOfAssAuctions(string id, CommentsContext commentsContext) { //returns query that gives auctions that are connected to actual user IQueryable <Auction> auctions; var MaxBids = ExtensionMethods.GetMaxBidsPerUser(ID, commentsContext); auctions = commentsContext.Auctions.Where(t => t.CreatorId == ID); auctions = auctions.Where(t => MaxBids.Contains(t.Id)); return(auctions); }
/// <summary> /// Возращает комментарий по id /// </summary> /// <param name="id"></param> /// <returns></returns> public static Comments Get(Guid id) { Comments comments; using (var db = new CommentsContext()) { comments = db.Comments.FirstOrDefault(d => d.Id == id); } return(comments); }
/// <summary> /// Отдает комментарии к публикации /// </summary> /// <param name="apod"></param> /// <returns></returns> public static int GetCountComments(NasaAPOD apod, bool isPublic = true) { var count = 0; if (apod == null) { return(0); } using (var db = new CommentsContext()) { count = db.Comments.Count(o => o.Post_Id == apod.Id && o.IsPublic == isPublic); } return(count); }
/// <summary> /// Отдает комментарии к публикации /// </summary> /// <param name="apod"></param> /// <returns></returns> public static List <Comments> GetListComments(NasaAPOD apod, bool isPublic = true) { var comments = new List <Comments>(); if (apod == null) { return(comments); } using (var db = new CommentsContext()) { comments = db.Comments.Where(o => o.Post_Id == apod.Id && o.IsPublic == isPublic).OrderBy(o => o.PublicateDate).ToList(); } return(comments); }
public ItemsController(ItemsContext context, ItemsService contextSearch, ICategoriesRepository categoryContext, IWebHostEnvironment hostEnvironment, IGendersRepository gendersContext, IFeaturesRepository featuresContext, ICommentsRepository commentsContext, CommentsContext comContext, UserManager <IdentityUser> userManager) { _categoryContext = categoryContext; _context = context; //_context2 = context2; _commentsContext = commentsContext; _gendersContext = gendersContext; _featuresContext = featuresContext; webHostEnvironment = hostEnvironment; _comContext = comContext; _contextSearch = contextSearch; this.userManager = userManager; }
public static List <string> GetMaxBidsPerUser(string id, CommentsContext context) { List <BidsModel> bids = context.Bids.Where(x => x.UserId == id).ToList(); var maxBids = from e in bids group e by e.UserId into Auct let top = Auct.Max(x => x.Value) select new BidsModel { UserId = Auct.Key, AuctionId = Auct.First(y => y.Value == top).AuctionId, Value = top, Id = Auct.First(y => y.Value == top).Id, }; return(maxBids.Select(t => t.AuctionId).ToList()); }
private List <CommentsView> GetComments(string id) { CommentsContext commentsContext = new CommentsContext(); IQueryable <Comments> query = commentsContext.Comment.Where(x => x.SellerId == id); List <Comments> commentsList = query.ToList(); //Builds container that have comment information after converting to userfriendly format List <CommentsView> commentsView = new List <CommentsView>(); foreach (Comments item in commentsList) { CommentsView row = new CommentsView(); row.AuctionUrl = "AuctionDetails.aspx?Id=" + item.AuctionId; Auction auction = ExtensionMethods.GetAuction(item.AuctionId); row.AuctionTitle = ExtensionMethods.GetAuction(item.AuctionId).Title; row.BuyerUrl = "CommentSite.aspx?Id=" + item.BuyerId; row.SellerUrl = "CommentSite.aspx?Id=" + item.SellerId; row.Description = item.Description; row.Rate = item.Rate; row.SellerName = ExtensionMethods.GetUserNameByID(item.SellerId); row.BuyerName = ExtensionMethods.GetUserNameByID(item.BuyerId); commentsView.Add(row); } return(commentsView); }
public TakeOffRepository(CommentsContext context) { this.db = context; }
public RequestForSpecificationRepository(CommentsContext context) { this.db = context; }
public CommentsRepo(CommentsContext db, ICommentLogger logger) { this.db = db; this.logger = logger; }
public CommentsController(CommentsContext context, UserManager <IdentityUser> userManager) { _context = context; this.userManager = userManager; }
public CommentsController(CommentsContext context) { db = context; }
public RequestForCorrectionRepository(CommentsContext context) { this.db = context; }
public NoteRepository(CommentsContext context) { this.db = context; }
public CommentsRepository(CommentsContext appDbContext) { _appDbContext = appDbContext; }
public ICommentsContext CreateConsumeCommentContext() => CommentsContext.Create(this);
public CommentRepository(CommentsContext CommentsContext) { db = CommentsContext; }
public RequestForUpdateStatusRepository(CommentsContext context) { this.db = context; }
public CommentsRepository() { _db = new CommentsContext(); }
public static Comments GetCommentFromAuction(string auctionId, string userId, CommentsContext context) { return(context.Comment.Where(x => x.AuctionId == auctionId && x.BuyerId == userId).SingleOrDefault()); }
public EFUnitOfWork(string connectionString) { db = new CommentsContext(connectionString); }
public RequestForTakeOffRepository(CommentsContext context) { this.db = context; }
public CorrectionRepository(CommentsContext context) { this.db = context; }
public CommentsController(CommentsContext context, IUserMock user) { this._context = context; this._user = user; this._loggerCommunication = new LoggerCommunication(); }
public TopicsController(CommentsContext context) { _context = context; }
public AdditionalRepository(CommentsContext context) { this.db = context; }
public AnswerToRequestSpecificationRepository(CommentsContext context) { this.db = context; }
public AnswerToRequestToTakeOffRepository(CommentsContext context) { this.db = context; }