Example #1
0
        public async Task <ActionResult> GetHomePageListAsync()
        {
            Domain.Segments.Hub hub  = new Domain.Segments.Hub();
            Domain.Resp         resp = await hub.GetHomePageListAsync();

            return(Pack(resp));
        }
Example #2
0
        public async Task <ActionResult> GetListAsync(int index, int rows, string order)
        {
            Domain.Segments.Hub hub  = new Domain.Segments.Hub();
            Domain.Resp         resp = await hub.GetListAsync(index, rows, order, Domain.Segments.Segment.SegmentState.Enabled);

            return(Pack(resp));
        }
Example #3
0
        public async Task <ActionResult> PublishAsync([FromForm] string content, [FromForm] string nickName)
        {
            Domain.Segments.Hub hub  = new Domain.Segments.Hub();
            Domain.Resp         resp = await hub.PublishAsync(content, nickName);

            return(Pack(resp));
        }
        public async Task <IActionResult> UnLikeAsync(int id)
        {
            Domain.Questions.Question question = Domain.Questions.Hub.GetQuestion(id);
            Domain.Resp r = await question.UnLikeAsync();

            return(Pack(r));
        }
Example #5
0
        public async Task <ActionResult> GetDetailAsync(int id)
        {
            Domain.Segments.Segment segment = Domain.Segments.Hub.GetSegment(id);
            Domain.Resp             resp    = await segment.GetDetail();

            return(Pack(resp));
        }
        public async Task <ActionResult> DeleteAsync(int id)
        {
            Domain.Segments.Hub hub  = new Domain.Segments.Hub();
            Domain.Resp         resp = await hub.Remove(id);

            return(Pack(resp));
        }
        public async Task <ActionResult> DisabledAsync(int id, [FromForm] string description)
        {
            Domain.Segments.Segment segment = Domain.Segments.Hub.GetSegment(id);
            Domain.Resp             detail  = await segment.DisabledAsync(description);

            return(Pack(detail));
        }
        public async Task <ActionResult> GetDetailAsync(int id)
        {
            Domain.Posts.Post post = Domain.Posts.Hub.GetPost(id);
            Domain.Resp       resp = await post.GetDetail();

            return(Pack(resp));
        }
Example #9
0
        public async Task <ActionResult> Liked(int id)
        {
            Domain.Segments.Segment segment = Domain.Segments.Hub.GetSegment(id);
            Domain.Resp             resp    = await segment.Liked();

            return(Pack(resp));
        }
Example #10
0
        public async Task <IActionResult> NewAskAsync([FromBody] Domain.Questions.Models.PostQuestion model)
        {
            model.UserId = CurrentUser.Id;
            Domain.Resp r = await CurrentUser.AskQuestion(model);

            return(Pack(r));;
        }
Example #11
0
        public async Task <ActionResult> Index([FromBody] Models.Login_Info info)
        {
            Hub hub = new Hub();

            Domain.Resp resp = await hub.Login(info);

            Results.Login_Result data = resp.GetData <Results.Login_Result>();
            if (data == Domain.Resp.NONE)
            {
                return(Pack(resp));
            }

            //  生成 JWT
            Claim[] claims = new Claim[]
            {
                new Claim(ClaimTypes.Authentication, data.Token.ToString()),
                new Claim(ClaimTypes.PrimarySid, data.Id.ToString())
            };
            string jwt = Auth.JWT.CreateJwtToken(claims);

            Response.Cookies.Append(Defaults.CLIENT_AUTH_COOKIE_KEY, jwt);

            resp.SetData(data.Account);

            return(Pack(resp));
        }
        public async Task <ActionResult> GetUserThemeList(string user, int index, int rows, string search)
        {
            Domain.Clients.Client client = Domain.Clients.Hub.GetClientByAccount(user);
            Domain.Resp           resp   = await client.GetSelfThemes(index, rows, search);

            return(Pack(resp));
        }
Example #13
0
        public async Task <ActionResult> Logout()
        {
            Domain.Resp resp = await CurrentAccount.Logout();

            Response.Cookies.Delete(Defaults.ADMIN_AUTH_COOKIE_KEY);
            return(Pack(resp));
        }
        public async Task <IActionResult> DeleteAsync(int id)
        {
            var questionHub = new Domain.Questions.Hub();

            Domain.Resp r = await questionHub.DeleteQuestionAsync(id, true);

            return(Pack(r));
        }
Example #15
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task <ActionResult> Index([FromBody] Models.Register_Info info)
        {
            Hub hub = new Hub();

            Domain.Resp resp = await hub.RegisterNewClient(info);

            return(Pack(resp));
        }
        public async Task <ActionResult> DisabledAsync(int id, [FromForm] string description)
        {
            Theme theme = Hub.GetTheme(id);

            Domain.Resp resp = await theme.DisabledAsync(description);

            return(Pack(resp));
        }
        public async Task <IActionResult> EnabledAsync(int id)
        {
            var answer = Domain.Answers.Hub.GetAnswer(id);

            Domain.Resp r = await answer.EnabledAsync();

            return(Pack(r));
        }
        public async Task <ActionResult> GetDetailAsync(int id)
        {
            Theme theme = Hub.GetTheme(id);

            Domain.Resp resp = await theme.GetDetailAsync();

            return(Pack(resp));
        }
        public async Task <ActionResult> AddThemeAsync(Domain.Themes.Models.NewTheme info)
        {
            Hub hub = new Hub();

            Domain.Resp resp = await hub.AddThemeAsync(info);

            return(Pack(resp));
        }
        public async Task <IActionResult> BackAsync(int id, string description)
        {
            var answer = Domain.Answers.Hub.GetAnswer(id);

            Domain.Resp r = await answer.BackAsync(description);

            return(Pack(r));
        }
Example #21
0
        public async Task <ActionResult> CreateAsync([FromBody] Models.NewTheme info)
        {
            info.CreateById = CurrentClient.Id;
            Hub hub = new Hub();

            Domain.Resp resp = await hub.AddThemeAsync(info);

            return(Pack(resp));
        }
        public async Task <ActionResult> GetListAsync(int index, int rows, string search)
        {
            if (string.IsNullOrWhiteSpace(search))
            {
                search = "";
            }
            Domain.Posts.Hub hub  = new Domain.Posts.Hub();
            Domain.Resp      resp = await hub.GetListAsync(index, rows, search, Domain.Posts.Post.PostState.Enabled);

            return(Pack(resp));
        }
        public async Task <IActionResult> PostComment(int id, [FromBody] Domain.Share.SingleContent model)
        {
            //  必须登录
            if (CurrentUser.IsEmpty())
            {
                return(Pack(Domain.Resp.NeedLogin()));
            }

            Domain.Questions.Question question = Domain.Questions.Hub.GetQuestion(id);
            Domain.Resp r = await question.AddCommentAsyns(CurrentUser.Id, model.Content);

            return(Pack(r));
        }
        public async Task <ActionResult> GetListAsync(int index, int rows, string search, string state)
        {
            if (string.IsNullOrWhiteSpace(search))
            {
                search = "";
            }
            Domain.Segments.Segment.SegmentState s = Domain.Segments.Segment.SegmentState.NotSelected;
            if (Enum.TryParse(typeof(Domain.Segments.Segment.SegmentState), state, true, out object result))
            {
                s = (Domain.Segments.Segment.SegmentState)result;
            }

            Domain.Segments.Hub hub  = new Domain.Segments.Hub();
            Domain.Resp         list = await hub.GetListAsync(index, rows, search, s);

            return(Pack(list));
        }
        public async Task <IActionResult> GetQuestionDetailAsync(int id, string title, int index, int size)
        {
            SetTitle(title);
            Domain.Paginator pager = Domain.Paginator.New(index, size, 1);
            pager["currentUserId"] = CurrentUser.Id.ToString();

            Domain.Questions.Question question = Domain.Questions.Hub.GetQuestion(id);
            Domain.Resp resp = await question.GetDetailAsync(Domain.Questions.Question.DetailSource.Client, pager);

            if (!resp.IsSuccess)
            {
                return(Redirect(string.Format($"/questions/?{ALERT_WARNING}", resp.Message)));
            }
            Domain.Questions.Results.QuestionDetailForClient model = resp.GetData <Domain.Questions.Results.QuestionDetailForClient>();

            return(View("QuestionDetail", model));
        }
        public async Task <ActionResult> GetListAsync(int index, int rows, string search, string state)
        {
            if (string.IsNullOrWhiteSpace(search))
            {
                search = "";
            }

            Theme.ThemeStates s = Theme.ThemeStates.NotSelected;
            if (Enum.TryParse(typeof(Theme.ThemeStates), state, true, out object result))
            {
                s = (Theme.ThemeStates)result;
            }

            Hub hub = new Hub();

            Domain.Resp resp = await hub.GetThemesAsync(index, rows, search, s, Theme.OrderBy.CreateDate);

            return(Pack(resp));
        }
        public async Task <IActionResult> PostReportAsync(int id, [FromBody] Domain.Questions.Models.NewReport model)
        {
            int reporterId;

            if (CurrentUser.IsEmpty())
            {
                reporterId = 0;
            }
            else
            {
                reporterId = CurrentUser.Id;
            }

            var question = Domain.Questions.Hub.GetQuestion(id);

            Domain.Resp r = await question.ReportAsync(model.Reason, model.Description, reporterId);

            return(Pack(r));
        }
        public async Task <ActionResult> Index()
        {
            Domain.Resp resp = await CurrentClient.Logout();

            return(Pack(resp));
        }