public async Task <FolderRestModel> CreateFolderAsync(FolderRestModel folder) { var response = await _httpService.PostAsync <FolderRestModel, FolderRestModel>(URL, folder); if (!response.IsSuccess) { throw new ApplicationException(await response.GetBodyAsync()); } return(response.Response); }
public async Task <FolderRestModel> UpdateAsync(FolderRestModel folder) { var uri = $"{URL}/{folder.Id}"; var response = await _httpService.UpdateAsync(uri, folder); if (!response.IsSuccess) { throw new ApplicationException(await response.GetBodyAsync()); } return(response.Response); }
public async Task <ActionResult <FolderRestModel> > Post(FolderRestModel folder) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var savedFolder = await _folderService.CreateFolderAsync(userId, _mapper.Map <Folder>(folder)); if (savedFolder == null) { return(Conflict()); } return(CreatedAtAction("POST", savedFolder.Id, _mapper.Map <FolderRestModel>(savedFolder))); }
public async Task <IActionResult> Put(int id, [FromBody] FolderRestModel folder) { if (id != folder.Id) { return(BadRequest()); } string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var updatedFolder = await _folderService.UpdateAsync(userId, _mapper.Map <Folder>(folder)); if (updatedFolder == null) { return(NotFound()); } return(Ok(_mapper.Map <FolderRestModel>(updatedFolder))); }