Пример #1
0
        public async Task <ActionResult <KnowledgeArticle_KnowledgeArticleDTO> > Delete([FromBody] KnowledgeArticle_KnowledgeArticleDTO KnowledgeArticle_KnowledgeArticleDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(KnowledgeArticle_KnowledgeArticleDTO.Id))
            {
                return(Forbid());
            }

            KnowledgeArticle KnowledgeArticle = ConvertDTOToEntity(KnowledgeArticle_KnowledgeArticleDTO);

            KnowledgeArticle = await KnowledgeArticleService.Delete(KnowledgeArticle);

            KnowledgeArticle_KnowledgeArticleDTO = new KnowledgeArticle_KnowledgeArticleDTO(KnowledgeArticle);
            if (KnowledgeArticle.IsValidated)
            {
                return(KnowledgeArticle_KnowledgeArticleDTO);
            }
            else
            {
                return(BadRequest(KnowledgeArticle_KnowledgeArticleDTO));
            }
        }
Пример #2
0
 public KnowledgeArticle_KnowledgeArticleKeywordDTO(KnowledgeArticleKeyword KnowledgeArticleKeyword)
 {
     this.Id   = KnowledgeArticleKeyword.Id;
     this.Name = KnowledgeArticleKeyword.Name;
     this.KnowledgeArticleId = KnowledgeArticleKeyword.KnowledgeArticleId;
     this.KnowledgeArticle   = KnowledgeArticleKeyword.KnowledgeArticle == null ? null : new KnowledgeArticle_KnowledgeArticleDTO(KnowledgeArticleKeyword.KnowledgeArticle);
     this.Errors             = KnowledgeArticleKeyword.Errors;
 }
Пример #3
0
        public async Task <ActionResult <KnowledgeArticle_KnowledgeArticleDTO> > Get([FromBody] KnowledgeArticle_KnowledgeArticleDTO KnowledgeArticle_KnowledgeArticleDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(KnowledgeArticle_KnowledgeArticleDTO.Id))
            {
                return(Forbid());
            }

            KnowledgeArticle KnowledgeArticle = await KnowledgeArticleService.Get(KnowledgeArticle_KnowledgeArticleDTO.Id);

            return(new KnowledgeArticle_KnowledgeArticleDTO(KnowledgeArticle));
        }
Пример #4
0
        private KnowledgeArticle ConvertDTOToEntity(KnowledgeArticle_KnowledgeArticleDTO KnowledgeArticle_KnowledgeArticleDTO)
        {
            KnowledgeArticle KnowledgeArticle = new KnowledgeArticle();

            KnowledgeArticle.Id           = KnowledgeArticle_KnowledgeArticleDTO.Id;
            KnowledgeArticle.Title        = KnowledgeArticle_KnowledgeArticleDTO.Title;
            KnowledgeArticle.Detail       = KnowledgeArticle_KnowledgeArticleDTO.Detail;
            KnowledgeArticle.StatusId     = KnowledgeArticle_KnowledgeArticleDTO.StatusId;
            KnowledgeArticle.GroupId      = KnowledgeArticle_KnowledgeArticleDTO.GroupId;
            KnowledgeArticle.CreatorId    = KnowledgeArticle_KnowledgeArticleDTO.CreatorId;
            KnowledgeArticle.DisplayOrder = KnowledgeArticle_KnowledgeArticleDTO.DisplayOrder;
            KnowledgeArticle.FromDate     = KnowledgeArticle_KnowledgeArticleDTO.FromDate;
            KnowledgeArticle.ToDate       = KnowledgeArticle_KnowledgeArticleDTO.ToDate;
            KnowledgeArticle.KMSStatusId  = KnowledgeArticle_KnowledgeArticleDTO.KMSStatusId;
            KnowledgeArticle.ItemId       = KnowledgeArticle_KnowledgeArticleDTO.ItemId;
            KnowledgeArticle.Creator      = KnowledgeArticle_KnowledgeArticleDTO.Creator == null ? null : new AppUser
            {
                Id             = KnowledgeArticle_KnowledgeArticleDTO.Creator.Id,
                Username       = KnowledgeArticle_KnowledgeArticleDTO.Creator.Username,
                DisplayName    = KnowledgeArticle_KnowledgeArticleDTO.Creator.DisplayName,
                Address        = KnowledgeArticle_KnowledgeArticleDTO.Creator.Address,
                Email          = KnowledgeArticle_KnowledgeArticleDTO.Creator.Email,
                Phone          = KnowledgeArticle_KnowledgeArticleDTO.Creator.Phone,
                SexId          = KnowledgeArticle_KnowledgeArticleDTO.Creator.SexId,
                Birthday       = KnowledgeArticle_KnowledgeArticleDTO.Creator.Birthday,
                Avatar         = KnowledgeArticle_KnowledgeArticleDTO.Creator.Avatar,
                PositionId     = KnowledgeArticle_KnowledgeArticleDTO.Creator.PositionId,
                Department     = KnowledgeArticle_KnowledgeArticleDTO.Creator.Department,
                OrganizationId = KnowledgeArticle_KnowledgeArticleDTO.Creator.OrganizationId,
                ProvinceId     = KnowledgeArticle_KnowledgeArticleDTO.Creator.ProvinceId,
                Longitude      = KnowledgeArticle_KnowledgeArticleDTO.Creator.Longitude,
                Latitude       = KnowledgeArticle_KnowledgeArticleDTO.Creator.Latitude,
                StatusId       = KnowledgeArticle_KnowledgeArticleDTO.Creator.StatusId,
            };
            KnowledgeArticle.Group = KnowledgeArticle_KnowledgeArticleDTO.Group == null ? null : new KnowledgeGroup
            {
                Id           = KnowledgeArticle_KnowledgeArticleDTO.Group.Id,
                Name         = KnowledgeArticle_KnowledgeArticleDTO.Group.Name,
                Code         = KnowledgeArticle_KnowledgeArticleDTO.Group.Code,
                StatusId     = KnowledgeArticle_KnowledgeArticleDTO.Group.StatusId,
                DisplayOrder = KnowledgeArticle_KnowledgeArticleDTO.Group.DisplayOrder,
                Description  = KnowledgeArticle_KnowledgeArticleDTO.Group.Description,
            };
            KnowledgeArticle.Status = KnowledgeArticle_KnowledgeArticleDTO.Status == null ? null : new Status
            {
                Id   = KnowledgeArticle_KnowledgeArticleDTO.Status.Id,
                Code = KnowledgeArticle_KnowledgeArticleDTO.Status.Code,
                Name = KnowledgeArticle_KnowledgeArticleDTO.Status.Name,
            };
            KnowledgeArticle.KnowledgeArticleOrganizationMappings = KnowledgeArticle_KnowledgeArticleDTO.KnowledgeArticleOrganizationMappings == null ? null : KnowledgeArticle_KnowledgeArticleDTO.KnowledgeArticleOrganizationMappings.Select(p => new KnowledgeArticleOrganizationMapping
            {
                OrganizationId     = p.OrganizationId,
                KnowledgeArticleId = KnowledgeArticle_KnowledgeArticleDTO.Id
            }).ToList();
            KnowledgeArticle.KnowledgeArticleKeywords = KnowledgeArticle_KnowledgeArticleDTO.KnowledgeArticleKeywords == null ? null : KnowledgeArticle_KnowledgeArticleDTO.KnowledgeArticleKeywords.Select(p => new KnowledgeArticleKeyword
            {
                Name = p.Name,
            }).ToList();
            KnowledgeArticle.BaseLanguage = CurrentContext.Language;
            return(KnowledgeArticle);
        }