public async Task <Response <UserDTO> > SaveNewAvatar(Guid userId, Guid resourceId) { var userEntity = await _repository.GetById(userId); if (userEntity == null) { return(new BusinessConflictErrorResponse <UserDTO>(new [] { new Error { Code = ErrorCodes.Business.UserDoesNotExists, Message = ErrorMessages.Business.UserDoesNotExists, Field = ErrorFields.User.Id } })); } if (userEntity.AvatarId != null) { var deleteResult = await _resourcesService.DeleteResource(userEntity.AvatarId.Value); } userEntity.AvatarId = resourceId; userEntity = await _repository.Update(userEntity); var result = _mapper.Map <UserModel, UserDTO>(userEntity); return(new Response <UserDTO> { Data = result }); }
public ActionResult DeleteSelected(ICollection <int> selectedIds) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageResource)) { return(AccessDeniedView()); } if (selectedIds != null) { var resources = _resourcesService.GetEntityByIds(selectedIds.ToArray()); foreach (var resource in resources) { _resourcesService.DeleteResource(resource);//删除本地 } } return(Json(new { Result = true })); }
public async void DeleteResource_ExistsInDb_ShouldRemove() { //arrange var dbResource = new Data.Model.Resource() { Id = Guid.NewGuid(), }; _dbResources.Add(dbResource); //act await _resourceService.DeleteResource(dbResource.Id); //assert var entity = _dbResources.FirstOrDefault(r => r.Id == dbResource.Id); Assert.Null(entity); }
public async Task DeleteResource(long id) { await _resourceService.DeleteResource(id); }
public async Task <IActionResult> Delete(Guid id) => await ReturnBadRequestIfThrowError(async() => await _resourcesService.DeleteResource(id));