public override object VisitComment(CommentContext context) { if (_currentClass != null || _currentEnum != null) { _currentComment = context.GetText(); } return(null); }
public static void EnsureSeedDataForContext(this CommentContext context) { if (context.users.Any()) { return; } var users = new List <User>() { new User() { FirstName = "Ali", LastName = "Baheri", Email = "*****@*****.**", Commnets = new List <Commnet>() { new Commnet() { Title = "Micanich", Description = "i'm in america and i'm good!" }, new Commnet() { Title = "Technical Ciense", Description = "i'm Michanic Student" } } }, new User() { FirstName = "Mohammad", LastName = "Ashabi", Email = "*****@*****.**", Commnets = new List <Commnet>() { new Commnet() { Title = "Chenistry", Description = "i'm in Iran and in Beheshti Uc i'm good!" }, new Commnet() { Title = "Pruposal", Description = "i'm Chemistry Student" }, new Commnet() { Title = "Hi!", Description = "i'm heare" } } } }; context.users.AddRange(users); context.SaveChanges(); }
public ItemController(TagContext tagContext, LikeContext likeContext, ItemContext context, CollectionContext collectionContext, UserManager <User> userManager, CommentContext commentContext) { _collectionContext = collectionContext; _itemContext = context; _userManager = userManager; _commentContext = commentContext; _likeContext = likeContext; _tagContext = tagContext; }
public static void EnsureSeedDataForContext(this CommentContext context) { if (context.Comments.Any()) { return; } // init seed data var comments = new List <Comment>() { new Comment() { Name = "Paragraph1", Description = "The fonction called is not given the expected result.", Seen = false, Replies = new List <Reply>() { new Reply() { Name = "Paragraph2", Seen = false, Description = "The compliler is not working properly." }, new Reply() { Name = "Paragraph3", Seen = false, Description = "I did not understand the exercise." }, } }, new Comment() { Name = "Paragraph2", Description = "The compliler is not working properly", Seen = false, Replies = new List <Reply>() { new Reply() { Name = "Paragraph2", Seen = false, Description = "Restart VS." }, new Reply() { Name = "Paragraph3", Seen = false, Description = "An explicit conversions exists, are you missing a cast?" }, } } }; context.Comments.AddRange(comments); context.SaveChanges(); }
public CommentService(IOptions <Settings> options, IMapper mapper) { if (options is null) { throw new ArgumentNullException(nameof(options)); } context = new CommentContext(options); this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); }
public CommentsController(CommentContext commentContext, QuestionContext questionContext, IConfiguration configuration) { _commentContext = commentContext; _questionContext = questionContext; _configuration = configuration; _conn = new SqlConnection(_configuration.GetConnectionString("DefaultConnection")); _comm = _conn.CreateCommand(); }
public CommentController(CommentContext context) { commentContext = context; if (commentContext.CommentItems.Count() == 0) { // Create a new item if collection is empty, which means you can't delete all items commentContext.CommentItems.Add(new CommentItem()); commentContext.SaveChanges(); } }
public CommentManager(CommentContext context) { _context = context; if (_context.Comments.Count() == 0) { _context.Comments.Add(new Comment { CommentID = 69420 }); _context.SaveChanges(); } }
public ArticleServiceImpl(ArticleContext articleContext, ClassificationContext classificationContext , CommentContext commentContext, TagContext tagContext , UserContext userContext , ReplyContext replyContext) { _articleContext = articleContext; _classificationContext = classificationContext; _commentContext = commentContext; _tagContext = tagContext; _userContext = userContext; _replyContext = replyContext; }
public Stock getOneStock(String name) { //Currently hard coded from viewing a list of stocks String url = "http://download.finance.yahoo.com/d/quotes.csv?s="; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url + name + "&f=nsl1h0o"); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); StreamReader sr = new StreamReader(resp.GetResponseStream()); string result = sr.ReadToEnd(); sr.Close(); Stock stock = new Stock(); using (CommentContext db = new CommentContext()) { StockComment com = db.StockComments.Find((String)Session["FBID"], name); if (com != null && com.Comment != null) { stock.Comment = com.Comment; } else { stock.Comment = ""; } } if (!string.IsNullOrWhiteSpace(result)) { String sn = result.Replace("\"", "").Replace(", ", " "); // Regex.Split(, "\r\n"); string[] stockInfo = sn.Split(','); if (!sn.Contains("N/A") && stockInfo.Length > 4) { stock.Ticker = stockInfo[1]; stock.Name = stockInfo[0]; stock.OpeningPrice = Convert.ToDouble(stockInfo[4]); stock.CurrentPrice = Convert.ToDouble(stockInfo[2]); stock.HighPrice = Convert.ToDouble(stockInfo[3]); } else { stock.Ticker = "NA"; stock.Name = "Not found"; stock.OpeningPrice = 0; stock.CurrentPrice = 0; stock.HighPrice = 0; } } return(stock); }
public async Task Comment_Content_Length_Equal_MaxLength() { // Setup var validator = new MaxLengthValidator(5); var content = "Hello"; var context = new CommentContext(content); // Act var result = await validator.ValidateAsync(context); // Assert Assert.IsTrue(result.Successed); }
public async Task Comment_Content_Length_Shorter_Than_MinLength() { // Setup var validator = new MinLengthValidator(5); var content = "Hi"; var context = new CommentContext(content); // Act var result = await validator.ValidateAsync(context); // Assert Assert.IsFalse(result.Successed); }
public async Task ReplyId_Is_Empty() { // Setup var commentsStorageMock = new Mock <ICommentsStorage>(); var validator = new CommentReplyValidator(commentsStorageMock.Object); var context = new CommentContext("Hello_Hello"); // Act var result = await validator.ValidateAsync(context); // Assert Assert.IsTrue(result.Successed); }
public CommentController(CommentContext context) { _context = context; if (_context.CommentItems.Count() == 0) { // Create a new CommentItem if collection is empty, // which means you can't delete all comments. _context.CommentItems.Add(new CommentItem { Name = "Comment1", IsPublic = true }); _context.SaveChanges(); } }
public Recipes(RecipeContext recipeContext, CommentContext commentContext) { this.recipeContext = recipeContext; this.commentContext = commentContext; foreach (var recipe in recipeContext.Recipes.OrderBy(r => - r.Votes)) { Lines.Add(new RecipeLine() { Recipe = recipe, NumberOfComments = commentContext.Comments.Where(c => c.RecipeId == recipe.Id).Count() //NumberOfComments = random.Next(5) }); } }
public CommentController(CommentContext context) { _context = context; for (int i = 1; i <= 5; i++) { if (_context.CommentItems.Count() >= 5) { break; } _context.CommentItems.Add(new Comment { Content = "Boooo", Photo_id = 1, Contact_id = 1 }); _context.SaveChangesAsync(); } }
/// <summary> /// Constructors for the Comment Controller /// </summary> /// <param name="context"></param> public CommentController(CommentContext context) { _context = context; if (_context.Comments.Count() == 0) { _context.Comments.Add(new Comment { CommentId = 111, MedicationPlanId = 333, AuthorId = 777, CommentSection = "This is a test", MessageRead = false, CreatedDate = DateTime.Now }); _context.Comments.Add(new Comment { CommentId = 222, MedicationPlanId = 333, AuthorId = 777, CommentSection = "This is a test 2", MessageRead = false, CreatedDate = DateTime.Now }); _context.SaveChanges(); } }
public ActionResult FuzzyMatches(long id) { var tweet = Tweet.GetTweet(id); var text = tweet.Text; using (var db = new CommentContext()) { var bestMatches = db.CommentReplies.OrderByDescending(x => Fuzzy.PartialRatio(x.CommentText, text)).Take(3).ToList(); var model = new FuzzyMatch { Tweet = tweet, CommentReplies = bestMatches }; return(View(model)); } }
public async Task ReplyId_Does_Not_Exists() { // Setup var commentsStorageMock = new Mock <ICommentsStorage>(); commentsStorageMock .Setup(s => s.FindOneByIdAsync("replyId")) .ReturnsAsync(default(Comment)); var validator = new CommentReplyValidator(commentsStorageMock.Object); var context = new CommentContext("Hello_Hello", "replyId"); // Act var result = await validator.ValidateAsync(context); // Assert Assert.IsFalse(result.Successed); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CommentContext commentContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); }); commentContext.EnsureSeedDataForContext(); app.UseMvc(); }
public async Task AddDownVote_AddsOneTo_DownVoteCount() { var comment = new Comment { Text = "IncrementCommentCountTest", User = "******" }; using (var context = new CommentContext(Options)) { context.Comments.Add(comment); await context.SaveChangesAsync(); await context.AddDownVoteAsync(comment.Id); await context.Entry(comment).ReloadAsync(); Assert.Equal(1, comment.DownVoteCount); } }
public CommentContext comment() { CommentContext _localctx = new CommentContext(Context, State); EnterRule(_localctx, 18, RULE_comment); try { EnterOuterAlt(_localctx, 1); { State = 68; Match(COMMENT); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public static void Initialize(CommentContext context) { context.Database.EnsureCreated(); if (context.Comments.Any()) { return; } var comments = new Comment[] { new Comment { UserID = "*****@*****.**", Text = "Перший коментар" } }; foreach (var item in comments) { context.Comments.Add(item); } context.SaveChanges(); }
static void Main(string[] args) { // The goal here is to read the json link and bulk insert to the database. IEnumerable <Comment> readComment = ReadComments().Result; // If the list is not Null read through the entire list perform bulk insert and use EntityFramework. if (readComment != null) { foreach (var item in readComment) { Console.WriteLine(item.postId + "\t\t" + item.name + "\t\t" + item.email + "\t\t" + item.body); CommentContext commentContext = new CommentContext(); Comment comment = new Comment(); comment.postId = item.postId; comment.name = item.name; comment.email = item.email; comment.body = item.body; commentContext.Comments.Add(comment); commentContext.SaveChanges(); Console.WriteLine("Successfully saved to the database!"); Console.WriteLine(); } } else { // If the list is null an error message will appear. Console.WriteLine("Error: Something went wrong!"); } Console.ReadLine(); }
public ActionResult Reply(long id, string text) { var tweet = Tweet.GetTweet(id); var publishedTweet = Auth.ExecuteOperationWithCredentials(Auth.Credentials, () => { var reply = $"@{tweet.CreatedBy.ScreenName} {text}"; return(Tweet.PublishTweetInReplyTo(reply, id)); }); if (publishedTweet != null) { using (var db = new CommentContext()) { var reply = new CommentReply { CommentText = Regex.Replace(tweet.Text, @"^@[^\s]+[\s]", ""), ReplyText = text }; db.CommentReplies.Add(reply); db.SaveChanges(); } } return(RedirectToAction("TweetPublished", new { id = publishedTweet?.Id, actionPerformed = "Publish", success = publishedTweet != null })); }
internal static List <VisitorComments> getAllComments(CommentContext _db) { return((from c in _db.Response select c).ToList()); }
internal static void addComment(CommentContext _db, VisitorComments comment) { _db.Response.Add(comment); _db.SaveChanges(); }
public ProductQuery(ShopContext context, DiscountContext discountContext, InventoryContext inventoryContext, CommentContext commentContext) { _context = context; _discountContext = discountContext; _inventoryContext = inventoryContext; _commentContext = commentContext; }
public ArticleQuery(BlogContext context, CommentContext commentContext) { _context = context; _commentContext = commentContext; }
public CommentRepository(CommentContext commentContext) => CommentContext = commentContext;
public CommentContext comment() { CommentContext _localctx = new CommentContext(Context, State); EnterRule(_localctx, 72, RULE_comment); int _la; try { EnterOuterAlt(_localctx, 1); { State = 1267; k_comment(); State = 1271; ErrorHandler.Sync(this); _la = TokenStream.La(1); while (_la==SCOL) { { { State = 1268; commparam(); } } State = 1273; ErrorHandler.Sync(this); _la = TokenStream.La(1); } State = 1274; Match(COL); State = 1275; text(); State = 1276; Match(CRLF); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }