public void AddTopic(string title) { Topic topic = new Topic { Title = title, DateCreated = DateTime.Now, UserID = HttpContext.Current.User.Identity.GetUserId() }; TopicsRepository.AddOrUpdateTopic(topic); //get all topics GetTopics(); }
public void AddComment(int id, string comment) { Comment c = new Comment { TopicID = id, Answer = comment, UserID = HttpContext.Current.User.Identity.GetUserId(), DateCreated = DateTime.Now, }; TopicsRepository.AddComment(c); GetComments(id); }
public ActionResult AddTopic(string topic) { if (!string.IsNullOrEmpty(topic)) { Topic t = new Topic { Title = topic, DateCreated = DateTime.Now, UserID = User.Identity.GetUserId() }; TopicsRepository.AddOrUpdateTopic(t); } return(RedirectToAction("Index")); }
public ActionResult AddComment(int topicid, string comment) { if (!string.IsNullOrEmpty(comment)) { Comment c = new Comment { TopicID = topicid, UserID = User.Identity.GetUserId(), Answer = comment, DateCreated = DateTime.Now }; TopicsRepository.AddComment(c); } return(RedirectToAction("Details", new { id = topicid })); }
public void GetTopics() { var topics = TopicsRepository.GetTopics(); var jsonRes = (from t in topics select new { Id = t.TopicID, Title = t.Title, DatePosted = t.DateCreated, User = ApplicationRepository.GetUserName(t.UserID) } ); Clients.All.loadTopics(jsonRes); }
public void GetComments(int id) { var topic = TopicsRepository.GetTopicByID(id); var jsonRes = (from c in topic.Comments select new { Id = c.CommentID, Answer = c.Answer, User = ApplicationRepository.GetUserName(c.UserID), DatePosted = c.DateCreated } ); Clients.All.loadComments(jsonRes); }
public ActionResult TopicThreads(Nullable<int> id) { IEnumerable<Thread> threads = default(IEnumerable<Thread>); if (id.HasValue) { using (var repo = new TopicsRepository()) { var topic = repo.GetById(id.Value); threads = topic.Threads; } } return View(threads); }
public void SetUp() { var connectionString = @"Data Source=ASHTON\ASHTON;Initial Catalog=LessonMonitorTestDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; _repository = new TopicsRepository(connectionString); }
public TopicsSearchProvider(ILogger <TopicsSearchProvider> logger, TopicsRepository topicsRepository, ISearcher searcher = null) : base( logger, searcher) { _topicsRepository = topicsRepository; }
public TopicsController(MasterDBContext db) { this._db = db; this._topicsRepository = new TopicsRepository(db); }
public ActionResult Details(int id) { var topic = TopicsRepository.GetTopicByID(id); return(View(topic)); }
// GET: Topics public ActionResult Index() { var topics = TopicsRepository.GetTopics(); return(View(topics)); }