Ejemplo n.º 1
0
        /// <summary>
        /// 获取API
        /// </summary>
        /// <param name="apiDocId"></param>
        /// <returns></returns>
        public API GetAPI(Id apiDocId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();
             var dbAPIDoc = from q in context.APIDocs
                      where q.APIDocId == apiDocId.Value
                      select q;

             return ConvertModelHelper.ToAPIModel(dbAPIDoc.First());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取Domain
        /// </summary>
        /// <param name="domainId"></param>
        /// <returns></returns>
        public Domain GetDomain(Id domainId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();

            var domain = (from q in context.Domains
                        where q.DomainId == domainId.Value
                        select q).FirstOrDefault();

            return ConvertModelHelper.ToDomainModel(domain);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取某Domain下的所有ErrorCode
        /// </summary>
        /// <param name="domainId"></param>
        /// <returns></returns>
        public IList<ErrorCode> GetErrorCodesInDomain(Id domainId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();

            var dbErrors = from q in context.Errors
                           where q.DomainId == domainId.Value
                           select q;

            return GetErrorCodeListFromDBErrorList(dbErrors.ToList());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取ErrorCode
        /// </summary>
        /// <param name="Code"></param>
        /// <returns></returns>
        public ErrorCode GetErrorCode(Id domainId, int Code)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();

            var dbmodel = (from q in context.Errors
                           where q.DomainId == domainId.Value && q.ErrorCode == Code
                           select q).FirstOrDefault();

            return ConvertModelHelper.ToErrorCodeModel(dbmodel);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取某API的ErrorCode
        /// </summary>
        /// <param name="apiDocId"></param>
        /// <returns></returns>
        public IList<ErrorCode> GetAPIErrorCodes(Id apiDocId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();

            var dbErrors = (from q in context.APIDocs
                           where q.APIDocId == apiDocId.Value
                           select q.Errors).FirstOrDefault();

            return GetErrorCodeListFromDBErrorList(dbErrors.ToList());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取目录下的API
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public IList<API> GetAllAPIInCategory(Id categoryId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();
            var dbAPIDoc = from q in context.APIDocs
                           where q.CategoryId == categoryId.Value
                           select q;

            IList<API> apiList = new List<API>();

            foreach (DBAPIDoc dbApi in dbAPIDoc)
            {
                apiList.Add(ConvertModelHelper.ToAPIModel(dbApi));
            }
            return apiList;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取Category
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public Category GetAPI(Id categoryId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();

            var category = (from q in context.Categories
                          where q.CategoryId == categoryId.Value
                          select q).FirstOrDefault();

            if (category != null)
            {
                var childCategories = from q in context.Categories
                                      where q.ParentId == category.CategoryId
                                      select q;

                return ConvertModelHelper.ToCategoryModel(category, childCategories.ToList());
            }

            else
                return null;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取目录下的Category
        /// </summary>
        /// <param name="domainId"></param>
        /// <returns></returns>
        public IList<Category> GetAllCategoryInDomain(Id domainId)
        {
            APIDoc_WebDBContext context = new APIDoc_WebDBContext();

            //IList<Category> categoryList;

            var dbCategoryList = from q in context.Categories
                               where q.DomainId == domainId.Value
                               select q;

            if (dbCategoryList != null)
            {
                IList<Category> categories = new List<Category>();
                foreach (DBCategory dbCategory in dbCategoryList)
                {
                    categories.Add(ConvertModelHelper.ToCategoryModel(dbCategory));
                }

                return categories;
            }

            else
                return null;
        }
Ejemplo n.º 9
0
        public static Category ToCategoryModel(DBCategory dbModel,List<Category> childCategories = null)
        {
            if(dbModel == null)return null;

            Id parentId;

            if (dbModel.ParentId.HasValue)
            {
                parentId = new Id(dbModel.ParentId.Value);
            }
            else
                parentId = null;
            return new Category
            {
                CategorySet = childCategories,
                Id = new Id(dbModel.CategoryId),
                DomainId = new Id(dbModel.DomainId),
                Title = dbModel.Title,
                ParentId = parentId
            };
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 设置API的ErrorCode
 /// </summary>
 /// <param name="apiDocId"></param>
 /// <param name="errorCodeId"></param>
 public bool SetAPIErrorCodes(Id apiDocId, List<int> errorCodeId)
 {
     return false;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 创建ErrorCode
 /// </summary>
 /// <param name="domain"></param>
 public bool Insert(ErrorCode errorCode, Id apiDocId = null)
 {
     return false;
 }