public ActionResult UploadDocument(TopicDetailModel _model, FormCollection formcollection) { List <SelectListItem> courseNames = new List <SelectListItem>(); TopicDetailModel topicDetailViewModel = new TopicDetailModel(); List <Courses_tb> Courses = Context.GetAllCoursesDetailsList().ToList <Courses_tb>(); var Topics = Context.GetTopicListAll(); Courses.ForEach(x => { courseNames.Add(new SelectListItem { Text = x.CourseName, Value = x.CoursesID.ToString() }); }); topicDetailViewModel.CourseNames = courseNames; ViewBag.Topics = Context.GetTopicListById(1); _model.CreatedDate = DateTime.Now; _model.UpdateDate = DateTime.Now; _model.isActive = true; _model.CourseId = Convert.ToInt32(formcollection["CourseId"]); _model.TopicId = Convert.ToInt32(formcollection["TopicId"]); var TopicPath = saveFileData(_model.TopicPath); Context.InsertTopicDetails(_model.TopicId, _model.TopicName, _model.TechnologyType, _model.PostedBy, _model.CreatedDate, _model.UpdateDate, _model.isActive, _model.CourseId, TopicPath); return(View(topicDetailViewModel)); }
/// <summary> /// 主题详细列表 /// </summary> /// <param name="topicId"></param> /// <param name="isTag"> 0表示所有楼层都显示 其它Id代表具体那楼层Id。</param> /// <returns></returns> public ActionResult TopicDetailList(int topicId, int floorId) { int CurrentUserId = GetCurrentUser().Id; WeixinApiInit(); @ViewBag.TopicId = topicId; IPostBarTopicBLL topicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL"); var topic = topicBll.GetEntity(m => m.Id == topicId); var model = new TopicDetailModel() { Id = topic.Id, Title = topic.Title, Content = topic.Content, PostUserId = topic.PostUserId, PostUserName = topic.PostUser.UserName, PostUserHeadPath = topic.PostUser.HeadPath, PostDate = TimeFormat(topic.PostDate), TopicImgPath = topic.ImgPath, PropertyPlaceId = topic.PropertyPlaceId, LevelOneReplyCount = topic.PostBarTopicDiscusss.Count(m => m.ParentId == null), CurrentUserId = CurrentUserId, IsTop = topic.IsTop, FloorId = floorId // 0表示所有楼层都显示 其它Id代表具体那楼层Id。 }; return(View(model)); }
public void Create_WithNonExistingItem_DoesNotThrow() { var model = new TopicDetailModel { heading = "Testovací téma", text = "Téma k InMemory testu" }; var returnedModel = _fixture.Repository.Add(model); var model1 = new TopicDetailModel { heading = "Testovací téma1", text = "Téma1 k InMemory testu" }; var returnedModel1 = _fixture.Repository.Add(model1); Assert.Equal(returnedModel1, returnedModel1); Assert.NotNull(returnedModel); _fixture.Repository.Update(returnedModel); Assert.NotNull(returnedModel); var returnedModel1After = _fixture.Repository.GetById(returnedModel1.Id); Assert.Equal(returnedModel1.heading, returnedModel1After.heading); _fixture.Repository.Remove(returnedModel.Id); _fixture.Repository.Remove(returnedModel1.Id); }
public async Task <IActionResult> PutTopic(Guid id, TopicDetailModel topic) { if (id != topic.Id) { return(BadRequest()); } _context.Entry(topic).State = EntityState.Modified; try { facade.Save(topic); } catch (DbUpdateConcurrencyException) { if (!TopicExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: Topic/Details/5 public ActionResult Details(int id) { var topicDetailModel = new TopicDetailModel() { Topic = topicFacade.GetTopicByID(id) }; return(View(topicDetailModel)); }
public static Topic MapTopicDetailModelToEntity(TopicDetailModel model) { return(new Topic() { Id = model.Id, date = model.date, heading = model.heading, text = model.text }); }
public TopicDetailModel Save(TopicDetailModel model) { if (model.Id == Guid.Empty) { return(repository.Add(model)); } else { repository.Update(model); return(model); } }
public void Update(TopicDetailModel detail) { using (var teamCommunicationDbContext = dbContextFactory.CreateDbContext()) { var topic = teamCommunicationDbContext.Topics.First(t => t.Id == detail.Id); topic.heading = detail.heading; topic.text = detail.text; teamCommunicationDbContext.SaveChanges(); } }
public JsonResult ReplyTopic(TopicDetailModel model) { JsonModel jm = new JsonModel(); try { int CurrentUserId = GetCurrentUser().Id; IPostBarTopicDiscussBLL replyTopicBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var replyTopic = new T_PostBarTopicDiscuss() { Content = model.ReplyTopicContent, ReplyId = model.PostUserId, PostUserId = CurrentUserId, PostTime = DateTime.Now, TopicId = model.Id }; //图片上传 if (!string.IsNullOrEmpty(model.ReplyTopicImgList)) { //图片集路径保存 replyTopic.ImgPath = GetMultimedia(ConstantParam.TOPIC_DIR, model.ReplyTopicImgList); StringBuilder imgsSB = new StringBuilder(); //生成缩略图保存 foreach (var path in replyTopic.ImgPath.Split(';')) { string thumpFile = DateTime.Now.ToFileTime() + ".jpg"; string thumpPath = Path.Combine(Server.MapPath(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId), thumpFile); PropertyUtils.getThumImage(Path.Combine(Server.MapPath(path)), 18, 3, thumpPath); imgsSB.Append(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId + "/" + thumpFile + ";"); } replyTopic.ImgThumbnail = imgsSB.ToString(); replyTopic.ImgThumbnail = replyTopic.ImgThumbnail.Substring(0, replyTopic.ImgThumbnail.Length - 1); } replyTopicBLL.Save(replyTopic); } catch (Exception ex) { jm.Msg = "回复主题失败"; PubFunction.ErrorLogPrint("话题圈回复错误:", ex.ToString()); } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult <TopicDetailModel> > PostTopic(TopicDetailModel detail) { DateTime date = DateTime.Now; TopicDetailModel topic = facade.CreateNew(); topic.TeamId = detail.TeamId; topic.UserId = detail.UserId; topic.date = date; topic.heading = detail.heading; topic.text = detail.text; if (facade.Save(topic) == null) { return(NotFound()); } return(Ok()); }
public ActionResult UploadDocument() { List <SelectListItem> courseNames = new List <SelectListItem>(); TopicDetailModel topicDetailViewModel = new TopicDetailModel(); List <Courses_tb> Courses = Context.GetAllCoursesDetailsList().ToList <Courses_tb>(); var Topics = Context.GetTopicListAll(); Courses.ForEach(x => { courseNames.Add(new SelectListItem { Text = x.CourseName, Value = x.CoursesID.ToString() }); }); topicDetailViewModel.CourseNames = courseNames; ViewBag.Topics = Context.GetTopicListById(1); return(View(topicDetailViewModel)); }
public TopicDetailModel Add(TopicDetailModel detail) { using (var teamCommunicationDbContext = dbContextFactory.CreateDbContext()) { var topic = TopicMapper.MapTopicDetailModelToEntity(detail); topic.Id = Guid.NewGuid(); var idUser = detail.UserId; var idTeam = detail.TeamId; if (idUser != Guid.Empty) { topic.User = teamCommunicationDbContext.Users.First(c => c.Id == idUser); } if (idTeam != Guid.Empty) { topic.Team = teamCommunicationDbContext.Teams.First(c => c.Id == idTeam); } teamCommunicationDbContext.Topics.Add(topic); teamCommunicationDbContext.SaveChanges(); return(TopicMapper.MapTopicEntityToDetailModel(topic)); } }
private bool TopicExists(Guid id) { TopicDetailModel topic = facade.GetTopic(id); return(topic == null ? false : true); }