public async Task <ActionResult> GetHomePageListAsync()
        {
            Domain.Posts.Hub hub  = new Domain.Posts.Hub();
            Domain.Resp      resp = await hub.GetHomePageListAsync();

            return(Pack(resp));
        }
Exemple #2
0
        public async Task <ActionResult> Publish([FromForm] Domain.Posts.Models.NewPostInfo info)
        {
            info.CreateById = CurrentClient.Id;
            List <Domain.Share.KeyValue <string, IFormFile> > files = new List <Domain.Share.KeyValue <string, IFormFile> >(Request.Form.Files.Count());

            foreach (var item in Request.Form.Files)
            {
                files.Add(new Domain.Share.KeyValue <string, IFormFile>
                {
                    Key   = item.Name,
                    Value = item
                });
            }
            info.Files = files;

            Resp resp;

            (bool isValid, string msg) = info.IsValid();

            if (!isValid)
            {
                resp = Resp.Fault(Resp.NONE, msg);
            }
            else
            {
                Domain.Posts.Hub hub = new Domain.Posts.Hub();
                resp = await hub.PublishNewPostAsync(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 <ActionResult> GetListAsync(int index, int rows, string search, string state)
        {
            if (string.IsNullOrWhiteSpace(search))
            {
                search = "";
            }

            Domain.Posts.Post.PostState s = Domain.Posts.Post.PostState.NotSelected;
            if (Enum.TryParse(typeof(Domain.Posts.Post.PostState), state, true, out object result))
            {
                s = (Domain.Posts.Post.PostState)result;
            }

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

            return(Pack(list));
        }