public async Task <IActionResult> GetAnyBranchAsync([FromQuery] BranchMinRequestModel requestModel, [FromRoute] string token) { if (token != Consts.StaticToken) { return(new ContentResult { StatusCode = 403 }); } try { var branchMinModel = await _branchManager.GetAnyBranchAsync(requestModel); return(Ok(branchMinModel)); } catch (KeyNotFoundException ex) { return(NotFound(ex.Message)); } }
/// <inheritdoc /> public async Task <BranchMin> GetAnyBranchAsync(BranchMinRequestModel requestModel) { if (requestModel == null) { throw new ArgumentNullException(nameof(requestModel)); } Branch branch = null; if (requestModel.Id.HasValue) { branch = await _branchRepository.GetAnyBranchAsync(requestModel.Id.Value); } else { branch = await _branchRepository.GetByAsync(x => x.BranchName == requestModel.BranchName); } if (branch == null) { throw new KeyNotFoundException(); } return(branch.Adapt <BranchMin>()); }