public TagDto Update(int id, UpdateTagDto dto) { var tagDto = dto.MapTo <TagDto>(); tagDto.Id = id; return(_tagAppService.Update(tagDto)); }
public void Validate_OK() { var dut = new UpdateTagDtoValidator(); var validUpdateTagDto = new UpdateTagDto(); var result = dut.Validate(validUpdateTagDto); Assert.IsTrue(result.IsValid); }
public async Task <TagDto> UpdateAsync(Guid id, UpdateTagDto input) { var tag = await _tagRepository.GetAsync(id); tag.SetName(input.Name); tag.SetDescription(input.Description); tag = await _tagRepository.UpdateAsync(tag); return(ObjectMapper.Map <Tag, TagDto>(tag)); }
public void Fail_WhenStorageAreaIsTooLong() { var dut = new UpdateTagDtoValidator(); var inValidUpdateTagDto = new UpdateTagDto() { Remark = "Remark", StorageArea = new string('x', Tag.StorageAreaLengthMax + 1) }; var result = dut.Validate(inValidUpdateTagDto); Assert.IsFalse(result.IsValid); }
//[AbpAuthorize(PermissionNames.Page_Tag_Update)] public async Task <bool> UpdateTagAsync(UpdateTagDto input) { PermissionChecker.Authorize(PermissionNames.Page_Tag_Update); var tag = await _tagRepository.GetAsync(input.Id); if (tag != null) { tag = input.MapTo(tag);//修改必须要 await _tagRepository.UpdateAsync(tag); return(true); } else { return(false); } }