Beispiel #1
0
 public Branch GetBranchByName(string name, int parentId = 0, int?revision = null)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(DbTypeConverter.MapBranch(context.Nodes_GetByName(parentId, name, revision).First()));
     }
 }
Beispiel #2
0
 public void DeleteBranch(int id, string author, string reason)
 {
     using (var context = new ApiDocDbDataContext())
     {
         context.Nodes_Delete(id, author, reason);
     }
 }
Beispiel #3
0
 public IList <Leaf> GetLeafes(int parentId, bool showDeleted = false)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(context.Leafes_GetAll(parentId, showDeleted)
                .Select(x => DbTypeConverter.MapLeaf(x, GetHttpVerbs())).ToList());
     }
 }
Beispiel #4
0
 public IList <Branch> GetBranchRevisions(string name, int parentId = 0)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(context.Nodes_GetRevisions(parentId, name)
                .Select(DbTypeConverter.MapBranch).ToList());
     }
 }
Beispiel #5
0
 public IList <Branch> GetBranches(int?parentId = 0, bool showDeleted = false)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(context.Nodes_GetAll(parentId, showDeleted)
                .Select(DbTypeConverter.MapBranch).ToList());
     }
 }
Beispiel #6
0
 public IList <Leaf> GetLeafRevisions(int parentId, string name, int?httpVerb)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(context.Leafes_GetRevisions(parentId, name, httpVerb)
                .Select(x => DbTypeConverter.MapLeaf(x, GetHttpVerbs())).ToList());
     }
 }
Beispiel #7
0
 public Leaf GetLeafByName(int parentId, string name, int?httpVerb, int?revision = null)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(DbTypeConverter.MapLeaf(
                    context.Leafes_GetByName(parentId, name, httpVerb, revision).First(),
                    GetHttpVerbs()));
     }
 }
Beispiel #8
0
 public int UpdateBranch(Branch newBranch)
 {
     using (var context = new ApiDocDbDataContext())
     {
         return(context.Nodes_Update(
                    newBranch.ParentId, newBranch.Id, newBranch.Name, newBranch.Description,
                    newBranch.Author, newBranch.ChangeNote));
     }
 }
Beispiel #9
0
 public void UpdateLeaf(Leaf newLeaf)
 {
     using (var context = new ApiDocDbDataContext())
     {
         var httpVerb = GetHttpVerbs().IdForName(newLeaf.HttpVerb);
         context.Leafes_Update(newLeaf.ParentId, newLeaf.Id, newLeaf.Name, httpVerb, newLeaf.Description,
                               newLeaf.RequiresAuthentication, newLeaf.RequiresAuthorization, newLeaf.SampleRequest, newLeaf.SampleResponse,
                               newLeaf.Author, newLeaf.ChangeNote);
     }
 }
Beispiel #10
0
        public HttpVerbs GetHttpVerbs()
        {
            if (_cachedHttpVerbs == null || DateTime.UtcNow > _cachedVerbsExpiry)
            {
                using (var context = new ApiDocDbDataContext())
                {
                    _cachedHttpVerbs = new HttpVerbs(
                        context.GetHttpVerbs().ToDictionary(x => x.fID, x => x.fHttpVerb));
                }
                _cachedVerbsExpiry = DateTime.UtcNow.AddHours(1);
            }

            return(_cachedHttpVerbs);
        }