コード例 #1
0
        public async Task <IHttpActionResult> CreateAsync(ContentLinkDto data)
        {
            var result = await _contentLinkService.CreateAsync(data);

            if (result == null)
            {
                return(BadRequest());
            }
            return(Ok(result));
        }
コード例 #2
0
        public async Task <IHttpActionResult> UpdateAsync(int id, ContentLinkDto data)
        {
            var result = await _contentLinkService.UpdateAsync(id, data);

            if (id != result.Id)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
コード例 #3
0
        public async Task <ContentLinkDto> UpdateAsync(int id, ContentLinkDto dto)
        {
            var link = await _unitOfWork.ContentLinks.GetByIdAsync(id);

            link.Name        = dto.Name;
            link.Description = dto.Description;
            link.Link        = dto.Link;
            link.LinkType    = dto.LinkType;
            link.IsDeleted   = dto.IsDeleted;

            await _unitOfWork.SaveChangesAsync();

            return(dto);
        }
コード例 #4
0
        public async Task <ContentLinkDto> CreateAsync(ContentLinkDto dto)
        {
            var link = new ContentLink
            {
                Name        = dto.Name,
                Description = dto.Description,
                IsDeleted   = false,
                Link        = dto.Link,
                LinkType    = dto.LinkType
            };

            _unitOfWork.ContentLinks.Create(link);
            await _unitOfWork.SaveChangesAsync();

            return(dto);
        }