コード例 #1
0
        public async Task CreateBranch(string branchName, string parentBranch = "")
        {
            var branch = new Branch
            {
                Id             = branchName,
                ParentBranchId = parentBranch,
                Path           = "",
                MetafilesHead  = new List <MetafileHead>(),
            };

            try
            {
                await _assetsStorage.CreateBranch(branch);
            }
            catch (BranchException ex)
            {
                var resp = new HttpResponseMessage(System.Net.HttpStatusCode.Conflict)
                {
                    Content      = new StringContent(ex.Message),
                    ReasonPhrase = ex.Message
                };
                throw new HttpResponseException(resp);
            }
            catch (ElasticsearchException)
            {
                var resp = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent($"Internal data base error please check server logs"),
                    ReasonPhrase = $"Internal data base error please check server logs"
                };
                throw new HttpResponseException(resp);
            }
        }