public async Task <IActionResult> DeleteBranch([FromQuery] string elementID, [FromQuery] string branchID) { try { ObjectId elementObjectID = ObjectId.Parse(elementID); ObjectId branchObjectID = ObjectId.Parse(branchID); ObjectId userID = ObjectId.Parse(tokenService.GetTokenClaim(requestService.GetToken(Request), "ID")); var elementDto = await branchService.DeleteBranchAsync(elementObjectID, branchObjectID, userID) .ConfigureAwait(false); return(new OkJson <DocumentElementDto>(elementDto)); } catch (FormatException) { return(new BadSentRequest <string>("This id is not in correct format")); } catch (ArgumentException ex) { return(new BadSentRequest <string>(ex.Message)); } catch (DatabaseException ex) { return(new InternalServerError(ex.Message)); } catch (Exception ex) { exceptionLogger.Log(new ApplicationError(ex), LogLevel.Error, logConfiguration); return(new InternalServerError()); } }
public async Task <IActionResult> DeleteBranchAsync([FromRoute] int branchId, CancellationToken cancellationToken = default) { try { var apiResponse = await _branchService.DeleteBranchAsync(branchId, cancellationToken); if (apiResponse.Success) { return(Ok(apiResponse)); } else if (apiResponse.Errors[0].Code == StatusCodes.Status404NotFound) { return(NotFound(apiResponse)); } return(BadRequest(apiResponse)); } catch (Exception exception) { return(_actionResultMapper.Map(exception)); } }
public async Task <IActionResult> DeleteBranchAsync(int id) { try { await _branchService.DeleteBranchAsync(id); return(Ok()); } catch (Exception e) { return(BadRequest(e)); } }