コード例 #1
0
        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));
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
ファイル: TopicRepositoryTests.cs プロジェクト: xberna16/FIT
        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);
        }
コード例 #4
0
ファイル: TopicsController.cs プロジェクト: xberna16/FIT
        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());
        }
コード例 #5
0
        // GET: Topic/Details/5
        public ActionResult Details(int id)
        {
            var topicDetailModel = new TopicDetailModel()
            {
                Topic = topicFacade.GetTopicByID(id)
            };

            return(View(topicDetailModel));
        }
コード例 #6
0
ファイル: TopicMapper.cs プロジェクト: xberna16/FIT
 public static Topic MapTopicDetailModelToEntity(TopicDetailModel model)
 {
     return(new Topic()
     {
         Id = model.Id,
         date = model.date,
         heading = model.heading,
         text = model.text
     });
 }
コード例 #7
0
ファイル: TopicFacade.cs プロジェクト: xberna16/FIT
 public TopicDetailModel Save(TopicDetailModel model)
 {
     if (model.Id == Guid.Empty)
     {
         return(repository.Add(model));
     }
     else
     {
         repository.Update(model);
         return(model);
     }
 }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
        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));
        }
コード例 #10
0
ファイル: TopicsController.cs プロジェクト: xberna16/FIT
        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());
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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));
            }
        }
コード例 #13
0
ファイル: TopicsController.cs プロジェクト: xberna16/FIT
        private bool TopicExists(Guid id)
        {
            TopicDetailModel topic = facade.GetTopic(id);

            return(topic == null ? false : true);
        }