/// <summary>
        /// Demonstrate the most efficient storage query - the point query - where both partition key and row key are specified.
        /// </summary>
        /// <param name="table">Sample table name</param>
        /// <param name="partitionKey">Partition key </param>
        /// <param name="rowKey">Row key </param>
        /// <returns>A Task object</returns>
        public async Task <TopicDetail> GetAllTopics()
        {
            try
            {
                common cmn = new common(_iconfiguration);
                // Create or reference an existing table
                CloudTable table = await cmn.CreateTableAsync("topic");

                TopicDetail topicDetail = new TopicDetail();

                TableQuery <Topic> tableQuery = new TableQuery <Topic>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "BhashaGuru"));

                //TableQuery<Topic> employeeQuery = new TableQuery<Topic>().Where(
                //TableQuery.CombineFilters(
                //TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey),
                //TableOperators.And,
                //TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThan, rowKey)));

                //retrives topic from the db
                var topics = await DataStorageUtils.ExecuteQueryAsync <Topic>(table, tableQuery);

                topicDetail.topic = topics;
                return(topicDetail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        /// <summary>
        /// 修改话题
        /// </summary>
        /// <param name="topicDetail"></param>
        /// <returns></returns>
        public JsonResult Update(TopicDetail topicDetail)
        {
            var jsonResult = new BaseResponse()
            {
            };

            if (topicDetail != null)
            {
                var result = TopicClient.Instance.UpdateTopic(topicDetail);

                if (result)
                {
                    jsonResult.DoFlag = true;
                }
                else
                {
                    jsonResult.DoResult = "更新失败,请重试!";
                }
            }
            else
            {
                jsonResult.DoResult = "参数错误!";
            }

            return(Json(jsonResult));
        }
Exemple #3
0
        public ActionResult AddArticle(TopicDetail Topic)
        {
            if (Topic.Id > 0)
            {
                TopicDetail model = TopicDetailServive.QueryWhere(a => a.Id == Topic.Id).FirstOrDefault();

                if (model != null)
                {
                    model.tdDetail        = Topic.tdDetail;
                    model.tdName          = Topic.tdName;
                    model.tdSectendDetail = Topic.tdSectendDetail;
                    model.tdLogo          = Topic.tdLogo;
                    model.TopicId         = Topic.TopicId;
                    model.tdContent       = Topic.tdContent;
                    model.tdTop           = Topic.tdTop;

                    TopicDetailServive.Edit(model);
                    TopicDetailServive.SaverChanges();
                    return(Content("<script type='text/javascript'>alert('厉害啦!更新成功!');window.location='/admin/Topic/TopicArticle';</script>"));
                }
                else
                {
                    return(Content("<script type='text/javascript'>alert('错啦错啦,没这个数据!');window.location='/admin/Topic/AddArticle';</script>"));
                }
            }
            else
            {
                Topic.tdCreatetime = DateTime.Now;
                TopicDetailServive.Add(Topic);
                TopicDetailServive.SaverChanges();
                return(Content("<script type='text/javascript'>alert('厉害啦!添加成功!');window.location='/admin/Topic/TopicArticle';</script>"));
            }
        }
        public async Task <IDetail> GetDetail()
        {
            JObject     o;
            IDetail     d;
            DataUriType type;

            switch (ListType)
            {
            case FeedListType.UserPageList:
                type = DataUriType.GetUserSpace;
                d    = new UserDetail();
                break;

            case FeedListType.TagPageList:
                type = DataUriType.GetTagDetail;
                d    = new TopicDetail();
                break;

            case FeedListType.DyhPageList:
                type = DataUriType.GetDyhDetail;
                d    = new DyhDetail();
                break;

            default:
                throw new System.Exception("ListType值错误");
            }
            o = (JObject)await DataHelper.GetDataAsync(type, Id);

            if (o != null)
            {
                d.Initialize(o);
            }
            Title = GetTitleBarText(d);
            return(d);
        }
Exemple #5
0
        public async Task <MessageModel <string> > Post([FromBody] TopicDetail topicDetail)
        {
            var data = new MessageModel <string>();

            if (topicDetail != null && topicDetail.Id > 0)
            {
                data.Success = await _topicDetailServices.Update(topicDetail);

                if (data.Success)
                {
                    data.Msg      = "更新成功";
                    data.Response = topicDetail?.Id.ObjToString();
                }
            }
            else
            {
                topicDetail.tdCreatetime = DateTime.Now;
                topicDetail.tdRead       = 0;
                topicDetail.tdCommend    = 0;
                topicDetail.tdGood       = 0;
                topicDetail.tdTop        = 0;

                var id = (await _topicDetailServices.Add(topicDetail));
                data.Success = id > 0;
                if (data.Success)
                {
                    data.Response = id.ObjToString();
                    data.Msg      = "添加成功";
                }
            }

            return(data);
        }
Exemple #6
0
        /// <summary>
        /// #region 获取话题题详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(int?id)
        {
            var viewModel = new TopicDetail();

            if (id > 0)
            {
                viewModel = TopicClient.Instance.GetTopicDetail(id.Value);

                viewModel.Images = TopicClient.Instance.GetTopicImages(id.Value);
            }
            return(View(viewModel));
        }
Exemple #7
0
        public ActionResult AddArticle(int id = 0)
        {
            ViewBag.UserName = LoginUser.uRealName;
            TopicDetail Topic = new TopicDetail();

            ViewBag.topic = TopicServive.QueryWhere(a => !a.tIsDelete).ToList();
            if (id > 0)
            {
                Topic = TopicDetailServive.QueryWhere(a => a.Id == id).FirstOrDefault();
            }
            return(View(Topic));
        }
        public async Task <MessageModel <string> > Post([FromBody] TopicDetail request)
        {
            var data = new MessageModel <string>();

            var id = await _topicDetailServices.Add(request);

            data.success = id > 0;

            if (data.success)
            {
                data.response = id.ObjToString();
                data.msg      = "添加成功";
            }

            return(data);
        }
Exemple #9
0
        public async Task <MessageModel <string> > Update([FromBody] TopicDetail topicDetail)
        {
            var data = new MessageModel <string>();

            if (topicDetail != null && topicDetail.Id > 0)
            {
                data.success = await _topicDetailServices.Update(topicDetail);

                if (data.success)
                {
                    data.msg      = "更新成功";
                    data.response = topicDetail?.Id.ObjToString();
                }
            }

            return(data);
        }
        public async Task <MessageModel <string> > Put([FromBody] TopicDetail request)
        {
            var data = new MessageModel <string>();

            if (request.Id > 0)
            {
                data.success = await _topicDetailServices.Update(request);

                if (data.success)
                {
                    data.msg      = "更新成功";
                    data.response = request?.Id.ObjToString();
                }
            }

            return(data);
        }
Exemple #11
0
 public int addTopicDetail(TopicDetail topicDetail)
 {
     string strSql = "insert into ex_topic_detail(topic_detail_id, topic_id, item_pre, item_detail, item_order, agreement) values(?topicDetailId, ?topicId, ?itemPre, ?itemDetail, ?itemOrder, ?agreement); select last_insert_id();";
     MySqlParameter[] parames = new MySqlParameter[] {
         new MySqlParameter("?topicDetailId", MySqlDbType.VarChar),
         new MySqlParameter("?topicId", MySqlDbType.VarChar),
         new MySqlParameter("?itemPre", MySqlDbType.VarChar),
         new MySqlParameter("?itemDetail", MySqlDbType.VarChar),
         new MySqlParameter("?itemOrder", MySqlDbType.VarChar),
         new MySqlParameter("?agreement", MySqlDbType.VarChar)
     };
     parames[0].Value = topicDetail.TopicDetailId;
     parames[1].Value = topicDetail.TopicId;
     parames[2].Value = topicDetail.ItemPre;
     parames[3].Value = topicDetail.ItemDetail;
     parames[4].Value = topicDetail.ItemOrder;
     parames[5].Value = topicDetail.Agreement;
     return Convert.ToInt32(MySqlHelper.ExecuteScalar(strSql, parames));
 }
Exemple #12
0
        public async Task <MessageModel <string> > Post([FromBody] TopicDetail topicDetail)
        {
            var data = new MessageModel <string>();

            topicDetail.tdCreatetime = DateTime.Now;
            topicDetail.tdRead       = 0;
            topicDetail.tdCommend    = 0;
            topicDetail.tdGood       = 0;
            topicDetail.tdTop        = 0;

            var id = (await _topicDetailServices.Add(topicDetail));

            data.success = id > 0;
            if (data.success)
            {
                data.response = id.ObjToString();
                data.msg      = "添加成功";
            }

            return(data);
        }
Exemple #13
0
        /// <summary>
        /// 从 TopicInfo 提取 TopicDetail
        /// </summary>
        /// <param name="topicInfo"></param>
        /// <param name="userId">当前用户编号,用于判断当前用户是否为帖子的发布者</param>
        /// <returns></returns>
        internal static TopicDetail ToTopicDetail(this TopicInfo topicInfo, int userId)
        {
            TopicDetail topic = new TopicDetail
            {
                Id                 = topicInfo.TopicId,
                Title              = topicInfo.Title,
                Owner              = UserBiz.ReadUserCacheInfo(topicInfo.UserId).ToUserBase(),
                IsRefined          = topicInfo.IsRefined,
                TopicType          = topicInfo.Reward > 0 ? TopicType.Reward : (topicInfo.IsQuestion ? TopicType.Questions : TopicType.Normal),
                RewardCount        = topicInfo.Reward,
                HasBestAnswer      = topicInfo.BestAnswerId > 0,
                FavouredCount      = topicInfo.FavouredCount,
                RepliedCount       = topicInfo.RepliedCount,
                PublishTime        = topicInfo.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
                AttachContent      = topicInfo.AttachContent,
                AttrChangedMark    = topicInfo.AttrChangedMark,
                ExpChanged         = topicInfo.ExpChanged,
                VirtualCoinChanged = topicInfo.VirtualCoinChanged,
                IFavoured          = true,
                BestReply          = null,
                Content            = topicInfo.Content.GetTopicContentList(),
                IsAllowReply       = topicInfo.IsAllowReply
            };

            if (userId != topicInfo.UserId)
            {
                topic.IFavoured = BbsBiz.UserFavouredTopic(userId, topicInfo.TopicId);
            }

            if (topic.HasBestAnswer)
            {
                PostInfo post = BbsBiz.GetPostInfoById(topicInfo.BestAnswerId);
                if (null != post)
                {
                    topic.BestReply = post.ToReplyDetail(userId);
                }
            }

            return(topic);
        }
Exemple #14
0
        public int addTopic(string topicContent)
        {
            Topic topic = new Topic();
            int flag = 0;
            if (topicContent != "")
            {
                string[] attrs = topicContent.Split(new char[] {'|'});
                string main = attrs[0];
                string detail = attrs[1];
                string[] mainDetail = main.Split(new char[] { ','});
                int topicId = Convert.ToInt32(mainDetail[4]);
                if (topicId == 0)                              //添加
                {
                    topic.Content = mainDetail[0];
                    topic.TopicType = mainDetail[1];
                    topic.TopicCategory = mainDetail[2];
                    topic.Answers = mainDetail[3];
                    flag = topicDao.addTopic(topic);
                    string[] dDetail = detail.Split(new char[] { ';' });
                    foreach (string dtl in dDetail)
                    {
                        if (dtl.IndexOf(",") > 0)
                        {
                            TopicDetail topicDetail = new TopicDetail();
                            string[] tpDetail = dtl.Split(new char[] { ',' });
                            topicDetail.TopicId = topic.TopicId;
                            topicDetail.ItemPre = tpDetail[0];
                            topicDetail.ItemDetail = tpDetail[1];
                            topicDetail.Agreement = tpDetail[2];
                            topicDetail.ItemOrder = tpDetail[3];
                            topicDetailDao.addTopicDetail(topicDetail);
                        }
                    }
                }
                else
                {
                    topic.TopicId = topicId;
                    topic.Content = mainDetail[0];
                    topic.TopicType = mainDetail[1];
                    topic.TopicCategory = mainDetail[2];
                    topic.Answers = mainDetail[3];
                    flag = topicDao.updateTopic(topic);

                    topicDetailDao.deleteTopicDetail(topicId);
                    string[] dDetail = detail.Split(new char[] { ';' });
                    foreach (string dtl in dDetail)
                    {
                        if (dtl.IndexOf(",") > 0)
                        {
                            TopicDetail topicDetail = new TopicDetail();
                            string[] tpDetail = dtl.Split(new char[] { ',' });
                            topicDetail.TopicId = topic.TopicId;
                            topicDetail.ItemPre = tpDetail[0];
                            topicDetail.ItemDetail = tpDetail[1];
                            topicDetailDao.addTopicDetail(topicDetail);
                        }
                    }
                }
            }
            return flag;
        }