Exemple #1
0
        public async Task <IActionResult> AddOrEditBranchAsync([FromRoute] int branchId, [FromBody] CreateBranchRequest request,
                                                               CancellationToken cancellationToken = default)
        {
            try
            {
                var apiResponse = await _branchService.AddOrEditBranchAsync(branchId, request, 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));
            }
        }