public async Task <Result <int, ErrorResponse> > HandleDeleteRequest(int websiteId) { var entity = await _websiteRepositoty.GetById(websiteId); if (entity is null) { return(Utility.ErrorResponseInt()); } await _websiteRepositoty.SoftDelete(entity); return(new Result <int, ErrorResponse> { IsSuccess = true, Success = websiteId }); }
public async Task <Result <WebsiteResponse, ErrorResponse> > HandleGetRequest(int websiteId) { var entity = await _websiteRepositoty.GetById(websiteId); if (entity is null) { return(Utility.ErrorResponse()); } var image = await _fileService.DownloadImage(entity.FilePath); var result = _mapper.EntityToResponse(entity, image); return(new Result <WebsiteResponse, ErrorResponse> { IsSuccess = true, Success = result }); }
public async Task <Result <int, ErrorResponse> > HandleUpdateRequest(int websiteId, WebsiteRequest request) { var initialEntity = await _websiteRepositoty.GetById(websiteId); if (initialEntity is null) { return(Utility.ErrorResponseInt()); } var entity = await GetEntity(request, initialEntity.FilePath); await _websiteRepositoty.Update(entity); return(new Result <int, ErrorResponse> { IsSuccess = true }); }