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);
        }
Example #2
0
            public static CommentsContext Create(ParseInput input)
            {
                var instance = new CommentsContext(input);

                instance.Init();
                return(instance);
            }
Example #3
0
 /// <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);
        }
Example #5
0
        /// <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);
        }
Example #6
0
        /// <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);
        }
Example #7
0
        /// <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);
        }
Example #8
0
 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;
 }
Example #9
0
        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());
        }
Example #10
0
        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;
 }
Example #12
0
 public RequestForSpecificationRepository(CommentsContext context)
 {
     this.db = context;
 }
Example #13
0
 public CommentsRepo(CommentsContext db, ICommentLogger logger)
 {
     this.db     = db;
     this.logger = logger;
 }
Example #14
0
 public CommentsController(CommentsContext context, UserManager <IdentityUser> userManager)
 {
     _context         = context;
     this.userManager = userManager;
 }
 public CommentsController(CommentsContext context)
 {
     db = context;
 }
Example #16
0
 public RequestForCorrectionRepository(CommentsContext context)
 {
     this.db = context;
 }
Example #17
0
 public NoteRepository(CommentsContext context)
 {
     this.db = context;
 }
 public CommentsRepository(CommentsContext appDbContext)
 {
     _appDbContext = appDbContext;
 }
Example #19
0
 public ICommentsContext CreateConsumeCommentContext()
 => CommentsContext.Create(this);
Example #20
0
 public CommentRepository(CommentsContext CommentsContext)
 {
     db = CommentsContext;
 }
 public RequestForUpdateStatusRepository(CommentsContext context)
 {
     this.db = context;
 }
		public CommentsRepository()
		{
			_db = new CommentsContext();
		}
Example #23
0
 public static Comments GetCommentFromAuction(string auctionId, string userId, CommentsContext context)
 {
     return(context.Comment.Where(x => x.AuctionId == auctionId && x.BuyerId == userId).SingleOrDefault());
 }
Example #24
0
 public EFUnitOfWork(string connectionString)
 {
     db = new CommentsContext(connectionString);
 }
Example #25
0
 public RequestForTakeOffRepository(CommentsContext context)
 {
     this.db = context;
 }
 public CorrectionRepository(CommentsContext context)
 {
     this.db = context;
 }
Example #27
0
 public CommentsController(CommentsContext context, IUserMock user)
 {
     this._context             = context;
     this._user                = user;
     this._loggerCommunication = new LoggerCommunication();
 }
 public TopicsController(CommentsContext context)
 {
     _context = context;
 }
Example #29
0
 public AdditionalRepository(CommentsContext context)
 {
     this.db = context;
 }
 public AnswerToRequestSpecificationRepository(CommentsContext context)
 {
     this.db = context;
 }
Example #31
0
 public AnswerToRequestToTakeOffRepository(CommentsContext context)
 {
     this.db = context;
 }