public static Models.Forum GetForumParser(string content, string id) { var obj = JObject.Parse(content); string title = obj["theme"].ToString(); string place = obj["place"].ToString(); string schedules = obj["schedules"].ToString(); DateTime date = obj["date"].ToObject <DateTime>(); int seconds = obj["hour"].ToObject <int>(); TimeSpan hour = TimeSpan.FromSeconds(seconds); string remoteId = obj["id"].ToString(); Debug.WriteLine("[Forum API]: Forum theme:" + title); Debug.WriteLine("[Forum API]: Forum place:" + place); Debug.WriteLine("[Forum API]: Forum schedules:" + schedules); Debug.WriteLine("[Forum API]: Forum date:" + date.ToString()); Debug.WriteLine("[Forum API]: Forum hour:" + hour.ToString(@"hh\:mm\:ss")); Models.Forum forum = new Models.Forum { Title = title, Place = place, Schedules = schedules, Date = date, Hour = hour, RemoteId = remoteId }; return(forum); }
public ActionResult DeleteConfirmed(int id) { Models.Forum forum = db.Fora.Find(id); db.Fora.Remove(forum); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Models.Forum forum) { db.Fora.Add(forum); db.SaveChanges(); return(RedirectToAction("Index")); }
private async Task UpdateForum() { try { var editedForum = new Models.Forum() { Title = forum.Title, Description = forum.Description, EnableUpDownVotes = forum.EnableUpDownVotes, ForumId = id }; btnVisibility = "d-none"; submitVisibility = "d-inline-block"; var updated = await manageForums.UpdateForumAsync(editedForum); btnVisibility = "d-inline-block"; submitVisibility = "d-none"; navManager.NavigateTo("/admin/manage/forums/" + id); } catch (Exception ex) { btnVisibility = "d-inline-block"; submitVisibility = "d-none"; _showError = true; _errorMsg = ex.Message; } }
public ActionResult Edit(int id, Models.Forum forum) { db.Entry(forum).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name"); Models.Forum forum = db.Fora.Find(id); return(View(forum)); }
public async Task <IActionResult> AddForum(AddForumModel model) { //todo make proper picture upload var imageUri = ""; if (model.ImageUpload != null) { //var blockBlob = PostForumImage(model.ImageUpload); //imageUri = blockBlob.Uri.AbsoluteUri; } else { imageUri = "/images/users/default.jpg"; } var forum = new Models.Forum() { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forumService.Add(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <bool> PostForumAsync(Models.Forum forum) { var uri = new Uri(string.Format(Constants.RestUrl, "forums")); var body = ForumParser.PostForumBuilder(forum); Debug.WriteLine("[Forum API] - preparing to build content"); var content = new StringContent(body.ToString(), Encoding.UTF8, "application/json"); var contentString = await content.ReadAsStringAsync(); Debug.WriteLine("[Forum API] - content built: " + contentString); try { var response = await _client.PostAsync(uri, content); if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsStringAsync(); Debug.WriteLine("[Forum API] - Post result: " + responseContent); return(true); } else { var failedContent = await response.Content.ReadAsStringAsync(); Debug.WriteLine("[Forum API] - Post response unsuccessful " + failedContent); return(false); } } catch (Exception ex) { Debug.WriteLine("[Forum API exception]:" + ex.Message); return(false); } }
protected override async Task OnInitializedAsync() { forum = await manageForums.GetForumAsync(id); categories = await manageCategories.GetForumCategoriesAsync(id); blazorModal.OnConfirmDeleteForum += DeleteForumConfirmed; }
public ActionResult Delete(int id) { Models.Forum toDelete = db.Fora.Find(id); db.Fora.Remove(toDelete); db.SaveChanges(); return(RedirectToAction("Index")); }
protected override async Task OnParametersSetAsync() { var node = await NodeService.GetBySlugAsync( Constants.ForumsModule, Constants.ForumType, Slug); Forum = Models.Forum.Create(node); }
// GET: Theme public ActionResult Index(int?id = 1) //Создавая метод мы создаем точку входа. Для этого случая "~/Theme/Index/". id - аргумент, попадет в индекс из адресной строки по принципу id=2 "~/Theme/Index/2" { //int? значение может быть null ViewBag.ThemeId = id; Models.Forum forum = new Models.Forum(); ViewBag.Theme = forum.Theme.Find(id); return(View()); }
private static ForumListingModel BuildForumListing(Models.Forum forum) { return(new ForumListingModel { Id = forum.Id, ImageUrl = forum.ImageUrl, Name = forum.Title, Description = forum.Description }); }
public ActionResult Create([Bind(Include = "forumId,Name,description,date,isPublic")] Models.Forum forum) { if (ModelState.IsValid) { db.Fora.Add(forum); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(forum)); }
public ActionResult Edit([Bind(Include = "forumId,Name,description,date,isPublic")] Models.Forum forum) { if (ModelState.IsValid) { var idForum = forum.forumId; db.Entry(forum).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Discussion", new { id = idForum })); } return(View(forum)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Models.Forum forum = db.Fora.Find(id); if (forum == null) { return(HttpNotFound()); } return(View(forum)); }
public void Delete(Models.Forum forum) { var eventArgs = new ForumEventArgs() { Forum = forum }; if (Deleting.RaiseAndContinue(this, eventArgs)) { _databaseContext.Database.Delete(forum); Deleted.Raise(this, eventArgs); } else { CancelledByEvent.Raise(this, eventArgs); } }
private async Task CreateForum() { var newForum = new Models.Forum() { Title = forum.Title, EnableUpDownVotes = forum.EnableUpDownVotes, Description = forum.Description }; var added = await manageForums.CreateForumAsync(newForum); btnVisibility = "d-inline-block"; submitVisibility = "d-none"; forum.Title = string.Empty; forum.Description = string.Empty; titleClass = "form-control clear-validation"; textAreaClass = "mt-2 form-control clear-validation"; OnForumCreated?.Invoke(); }
public static JObject PutForumBuilder(Models.Forum oldForum, Models.Forum newForum) { var forumData = new JObject(); if (oldForum.Title != newForum.Title && !String.IsNullOrEmpty(newForum.Title)) { var theme = newForum.Title; forumData.Add("theme", theme); } if (oldForum.Place != newForum.Place && !String.IsNullOrEmpty(newForum.Place)) { var place = newForum.Place; forumData.Add("place", place); } if (oldForum.Schedules != newForum.Schedules && !String.IsNullOrEmpty(newForum.Schedules)) { var schedules = newForum.Schedules; forumData.Add("schedules", schedules); } if (oldForum.Date != newForum.Date && newForum.Date != null) { var date = newForum.Date; forumData.Add("date", date); } if (oldForum.Hour != newForum.Hour && newForum.Hour != null) { var hour = newForum.Hour.TotalSeconds; forumData.Add("hour", hour); } var body = new JObject(); body.Add("forum", forumData); return(body); }
public static JObject PostForumBuilder(Models.Forum forum) { var theme = forum.Title; var place = forum.Place; var schedules = forum.Schedules; var date = forum.Date; var hour = forum.Hour.TotalSeconds; var forumContents = new JObject(); forumContents.Add("theme", theme); forumContents.Add("place", place); forumContents.Add("schedules", schedules); forumContents.Add("date", date); forumContents.Add("hour", hour); var body = new JObject(); body.Add("forum", forumContents); return(body); }
void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs<Umbraco.Core.Models.IContent> e) { var fs = new ForumService(ApplicationContext.Current.DatabaseContext); foreach (var ent in e.PublishedEntities.Where(x => x.ContentType.Alias == "Forum")) { Models.Forum f = fs.GetById(ent.Id); if (f == null) { f = new Models.Forum(); f.Id = ent.Id; f.ParentId = ent.ParentId; f.SortOrder = ent.SortOrder; f.TotalTopics = 0; f.TotalComments = 0; f.LatestPostDate = DateTime.Now; f.LatestAuthor = 0; f.LatestComment = 0; f.LatestTopic = 0; fs.Save(f); } } }
public Models.Forum Save(Models.Forum forum) { var newForum = _databaseContext.Database.ExecuteScalar <int>("SELECT COUNT(*) FROM forumForums WHERE id=@id", new { id = forum.Id }) == 0; var eventArgs = new ForumEventArgs() { Forum = forum }; if (newForum) { Creating.Raise(this, eventArgs); } else { Updating.Raise(this, eventArgs); } if (!eventArgs.Cancel) { if (newForum) { _databaseContext.Database.Insert(forum); Created.Raise(this, eventArgs); } else { _databaseContext.Database.Update(forum); Updated.Raise(this, eventArgs); } } else { CancelledByEvent.Raise(this, eventArgs); } return(forum); }
void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs <Umbraco.Core.Models.IContent> e) { var fs = new ForumService(ApplicationContext.Current.DatabaseContext); foreach (var ent in e.PublishedEntities.Where(x => x.ContentType.Alias == "Forum")) { Models.Forum f = fs.GetById(ent.Id); if (f == null) { f = new Models.Forum(); f.Id = ent.Id; f.ParentId = ent.ParentId; f.SortOrder = ent.SortOrder; f.TotalTopics = 0; f.TotalComments = 0; f.LatestPostDate = DateTime.Now; f.LatestAuthor = 0; f.LatestComment = 0; f.LatestTopic = 0; fs.Save(f); } } }
private async Task CreateForum_cc98() { //============================================================================== //============================================================================== var forum1 = new Models.Forum() { Title = "学习", EnableUpDownVotes = true, Description = "关于学习的模块" }; await manageForums.CreateForumAsync(forum1); var category1_1 = new Models.ForumCategory() { Title = "学习天地 ^_^", Description = "交流经验,答疑解惑,相互促进,共同进步", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_1); var category1_2 = new Models.ForumCategory() { Title = "外语学习 ^_^", Description = "让不同的语言,不同的文化在这里碰撞,擦出美丽的思想的火花~~", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_2); var category1_3 = new Models.ForumCategory() { Title = "留学交流 ^_^", Description = "留洋人聚集的广场,G、T经验交流的场所", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_3); var category1_4 = new Models.ForumCategory() { Title = "考研一族 ^_^", Description = "艰难困苦,玉汝于成;考研路上,你我同行", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_4); var category1_5 = new Models.ForumCategory() { Title = "编程技术 ^_^", Description = "C/C++, Pascal, Basic, Lisp, Perl/Python/Ruby...Anything you want", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_5); var category1_6 = new Models.ForumCategory() { Title = "编程答疑 ^_^", Description = "编程基础问题解答,ACM-ICPC、算法问题讨论", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_6); var category1_7 = new Models.ForumCategory() { Title = "社科学术 ^_^", Description = "历史、哲学、军事、艺术、科技、经济、政法,可讨论相关话题", ForumId = forum1.ForumId }; await manageCategories.CreateCategoryAsync(category1_7); //============================================================================== //============================================================================== //============================================================================== var forum2 = new Models.Forum() { Title = "信息", EnableUpDownVotes = true, Description = "test cc98 02" }; await manageForums.CreateForumAsync(forum2); var category2_1 = new Models.ForumCategory() { Title = "校园信息 ^_^", Description = "知人所道,道己所知", ForumId = forum2.ForumId }; await manageCategories.CreateCategoryAsync(category2_1); var category2_2 = new Models.ForumCategory() { Title = "研究生 ^_^", Description = "选课题?月钱?毕业论文?这里是研究生学习、生活、工作的交流平台", ForumId = forum2.ForumId }; await manageCategories.CreateCategoryAsync(category2_2); var category2_3 = new Models.ForumCategory() { Title = "新生宝典 ^_^", Description = "构建新老生交流平台,以有限的空间满足无限的需要", ForumId = forum2.ForumId }; await manageCategories.CreateCategoryAsync(category2_3); //============================================================================== //============================================================================== var forum3 = new Models.Forum() { Title = "兴趣", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum3); var category3_1 = new Models.ForumCategory() { Title = "数码世界 ^_^", Description = "digi……", ForumId = forum3.ForumId }; await manageCategories.CreateCategoryAsync(category3_1); var category3_2 = new Models.ForumCategory() { Title = "电脑医院 ^_^", Description = "有电脑应用或者网络的问题?砸过来讨论吧~这里是你技术进阶的乐园^_^", ForumId = forum3.ForumId }; await manageCategories.CreateCategoryAsync(category3_2); var category3_3 = new Models.ForumCategory() { Title = "动漫讨论 ^_^", Description = "动风抚心,漫影舞情;动漫天地,美好永远", ForumId = forum3.ForumId }; await manageCategories.CreateCategoryAsync(category3_3); //============================================================================== //============================================================================== var forum4 = new Models.Forum() { Title = "交易", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum4); var category4_1 = new Models.ForumCategory() { Title = "生活点滴 ^_^", Description = "点滴生活,你我共享", ForumId = forum4.ForumId }; await manageCategories.CreateCategoryAsync(category4_1); var category4_2 = new Models.ForumCategory() { Title = "数码交易 ^_^", Description = "电脑周边,数码产品", ForumId = forum4.ForumId }; await manageCategories.CreateCategoryAsync(category4_2); var category4_3 = new Models.ForumCategory() { Title = "服饰美肤 ^_^", Description = "衣裤鞋包,护肤化妆", ForumId = forum4.ForumId }; //============================================================================== var forum5 = new Models.Forum() { Title = "情感", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum5); var forum6 = new Models.Forum() { Title = "生活", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum6); var forum7 = new Models.Forum() { Title = "教师答疑", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum7); var forum8 = new Models.Forum() { Title = "院系交流", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum8); var forum9 = new Models.Forum() { Title = "社团风采", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum9); var forum10 = new Models.Forum() { Title = "天下一家", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum10); var forum11 = new Models.Forum() { Title = "cc98协会", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum11); var forum12 = new Models.Forum() { Title = "论坛管理", EnableUpDownVotes = true, Description = "test cc98 03" }; await manageForums.CreateForumAsync(forum12); btnVisibility = "d-inline-block"; submitVisibility = "d-none"; OnForumCreated?.Invoke(); }
protected override async Task OnInitializedAsync() { forum = await manageForums.GetForumAsync(id); }
private async Task CreateForum_Course() { //============================================================================== var forum0 = new Models.Forum() { Title = "选课交流", EnableUpDownVotes = true, Description = "关于选课的模块" }; await manageForums.CreateForumAsync(forum0); var category0_1 = new Models.ForumCategory() { Title = "选课交流", Description = "交流经验,相互促进,共同进步", ForumId = forum0.ForumId, ForumCategoryUrl = "Elective" }; await manageCategories.CreateCategoryAsync(category0_1); //============================================================================== var forum1 = new Models.Forum() { Title = "软件工程", EnableUpDownVotes = true, Description = "关于软件工程课程的模块" }; await manageForums.CreateForumAsync(forum1); await addSubmoduleOfCourse(forum1.ForumId); var forum2 = new Models.Forum() { Title = "B/S体系软件设计", EnableUpDownVotes = true, Description = "关于B/S体系软件设计课程的模块" }; await manageForums.CreateForumAsync(forum2); await addSubmoduleOfCourse(forum2.ForumId); var forum3 = new Models.Forum() { Title = "编译原理", EnableUpDownVotes = true, Description = "关于编译原理课程的模块" }; await manageForums.CreateForumAsync(forum3); await addSubmoduleOfCourse(forum3.ForumId); var forum4 = new Models.Forum() { Title = "操作系统", EnableUpDownVotes = true, Description = "关于操作系统课程的模块" }; await manageForums.CreateForumAsync(forum4); await addSubmoduleOfCourse(forum4.ForumId); var forum5 = new Models.Forum() { Title = "计算机网络", EnableUpDownVotes = true, Description = "关于计算机网络课程的模块" }; await manageForums.CreateForumAsync(forum5); await addSubmoduleOfCourse(forum5.ForumId); //============================================================================== btnVisibility = "d-inline-block"; submitVisibility = "d-none"; OnForumCreated?.Invoke(); }
public string GetAuthor(Models.Forum forum) { return(forum.Users.Find(theme.IdAutor).Nik); }