public async ValueTask <KSociety.Com.App.Dto.Res.Copy.Common.Tag> ExecuteAsync(Tag request, CancellationToken cancellationToken = default) { var commonTag = _mapper.Map <Domain.Entity.Common.Tag>(request); await _tagRepository.AddAsync(commonTag, cancellationToken).ConfigureAwait(false); return(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) == -1 ? new KSociety.Com.App.Dto.Res.Copy.Common.Tag(Guid.Empty) : new KSociety.Com.App.Dto.Res.Copy.Common.Tag(commonTag.Id)); }
public async Task <Response <TagModel> > Post([FromBody] TagModel model) { Response <TagModel> tagResponseModel = new Response <TagModel>(); try { Tag entity = _mapper.Map <Tag>(model); entity = await(model.Id != Guid.Empty ? _tag.UpdateAsync(entity) : _tag.AddAsync(entity)); tagResponseModel.Value = _mapper.Map <TagModel>(entity); tagResponseModel.IsSuccess = true; } catch (Exception e) { tagResponseModel.Exception = e; tagResponseModel.IsSuccess = false; } return(tagResponseModel); }