Exemple #1
0
        public async Task OnGetAsync(long?id, long?pid)
        {
            if (id.HasValue)
            {
                //编辑
                Dto = await _service.GetByIdAsync(id.Value);

                if (Dto == null)
                {
                    throw new KuDataNotFoundException("无法取得数据!");
                }
                if (Dto.ParentId.HasValue)
                {
                    Parents = await _service.GetParentsAsync(Dto.ParentId.Value);
                }

                ViewData["Mode"] = "Edit";
            }
            else
            {
                //新增
                Dto = new ColumnDto();
                if (pid.HasValue)
                {
                    Dto.ParentId = pid.Value;
                    Parents      = await _service.GetParentsAsync(pid.Value);
                }
                else
                {
                    Dto.ParentId = null;
                }
                ViewData["Mode"] = "Add";
            }
        }
Exemple #2
0
        public async Task OnGetAsync(long?id, long?ColumnId)
        {
            if (id.HasValue)
            {
                Dto = await _service.GetByIdAsync(id.Value);

                if (Dto == null)
                {
                    throw new KuDataNotFoundException();
                }
                Dto.Column = await _service2.GetByIdAsync(Dto.ColumnId);

                if (Dto.Column == null)
                {
                    throw new KuDataNotFoundException("数据出错!");
                }
                ViewData["Mode"] = "Edit";
            }
            else
            {
                Dto = new ArticleDto();
                if (ColumnId.HasValue)
                {
                    Dto.ColumnId = ColumnId.Value;
                    Dto.Column   = await _service2.GetByIdAsync(ColumnId.Value);

                    if (Dto.Column == null)
                    {
                        throw new KuDataNotFoundException("参数出错!");
                    }
                }
                else
                {
                    throw new KuDataNotFoundException("参数出错!");
                }
                ViewData["Mode"] = "Add";
            }
        }
Exemple #3
0
        public async Task <IActionResult> GetById(int id)
        {
            var column = await _columnService.GetByIdAsync(id);

            return(Ok(column));
        }
Exemple #4
0
        public async Task OnGetAsync(long?id, long?ColumnId, long?albumId)
        {
            if (id.HasValue)
            {
                Dto = await _service.GetByIdAsync(id.Value);

                if (Dto == null)
                {
                    throw new KuDataNotFoundException();
                }
                if (Dto.ColumnId.HasValue)
                {
                    Dto.Column = await _service2.GetByIdAsync(Dto.ColumnId.Value);

                    if (Dto.Column == null)
                    {
                        throw new KuDataNotFoundException("数据出错!");
                    }
                }
                if (Dto.AlbumId.HasValue)
                {
                    Dto.Album = await _service3.GetByIdAsync(Dto.AlbumId.Value);

                    if (Dto.Album == null)
                    {
                        throw new KuDataNotFoundException("数据出错!");
                    }
                }

                ViewData["Mode"] = "Edit";
            }
            else
            {
                Dto = new ArticleDto();
                if (albumId.HasValue)
                {
                    Dto.ContentType = Domain.Enum.Content.EmArticleContentType.Video;
                    Dto.AlbumId     = albumId.Value;
                    Dto.Album       = await _service3.GetByIdAsync(albumId.Value);

                    if (Dto.Album == null)
                    {
                        throw new KuDataNotFoundException("参数出错!");
                    }
                }
                else
                {
                    Dto.ContentType = Domain.Enum.Content.EmArticleContentType.RichText;
                }
                Dto.IsPublished = true;
                if (ColumnId.HasValue)
                {
                    Dto.ColumnId = ColumnId.Value;
                    Dto.Column   = await _service2.GetByIdAsync(ColumnId.Value);

                    if (Dto.Column == null)
                    {
                        throw new KuDataNotFoundException("参数出错!");
                    }
                }
                ViewData["Mode"] = "Add";
            }
        }