Beispiel #1
0
        public async Task <IActionResult> CreateNewBranch([FromQuery] string elementID, [FromQuery] string branchName)
        {
            try
            {
                ObjectId elementObjectID = ObjectId.Parse(elementID);
                ObjectId userID          = ObjectId.Parse(tokenService.GetTokenClaim(requestService.GetToken(Request), "ID"));

                var elementDto = await branchService.CreateNewBranchAsync(elementObjectID, branchName, 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());
            }
        }