Пример #1
0
        public List <CategoryTree> GetCategoryTree(int tenandId = 0)
        {
            CategoriesService Category = new CategoriesService();
            var result = Category.Reposity.GetAllList();

            if (tenandId > 0)
            {
                result = result.Where(o => o.TenantId == tenandId).ToList();
            }

            List <Categories> lists = new List <Categories>();

            CreateTree(lists, result);
            var elist = Mapper.Map <List <CategoryTree> >(lists);

            foreach (var item in elist)
            {
                string prev = "";
                if (item.Level > 0)
                {
                    prev = "└";
                    for (int i = 0; i < item.Level; i++)
                    {
                        prev += "─";
                    }
                }
                item.PrevStr = prev;
            }
            Category.Dispose();
            return(elist);
        }
Пример #2
0
        protected override void Dispose(bool disposing)
        {
            _productService.Dispose();
            _categoriesService.Dispose();

            base.Dispose(disposing);
        }
Пример #3
0
        public JsonResult GetLists(int page, int pageSize)
        {
            CategoriesService Category = new CategoriesService();
            var result = Category.Reposity.GetPageList(page, pageSize, (o => o.TenantId == TenantId));

            Category.Dispose();
            return(Json(result));
        }
Пример #4
0
        public JsonResult GetListByCategory(string CateName)
        {
            CategoriesService Category = new CategoriesService();
            var categories             = Category.Reposity.GetAllList(o => o.TenantId == TenantId && o.CategoryIndex == CateName);
            List <Categories> lists    = new List <Categories>();

            CreateTree(lists, categories);
            Category.Dispose();
            return(Json(lists));
        }
Пример #5
0
        public JsonResult CreateOrUpdate(ArticleInput model)
        {
            ResultDto <long> result = new ResultDto <long>();

            try
            {
                ArticlesService   ArticleRead = new ArticlesService();
                ArticlesService   Article     = new ArticlesService();
                CategoriesService Category    = new CategoriesService();
                var input = Mapper.Map <Articles>(model);
                if (input.Id == 0)
                {
                    input.CreationTime = DateTime.Now;
                }
                else
                {
                    input.Category = Category.Reposity.Get(input.CategoryId);
                    //input.UpdateTime = DateTime.Now;
                    input.CreationTime = ArticleRead.Reposity.Get(input.Id).CreationTime;
                }
                input.Contents = HttpUtility.HtmlDecode(input.Contents);
                input.TenantId = TenantId;

                Article.Reposity.InsertOrUpdate(input);
                result.code    = 100;
                result.datas   = input.Id;
                result.message = "ok";
                Category.Dispose();
                Article.Dispose();
                ArticleRead.Dispose();
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }
Пример #6
0
        public JsonResult GetModelWithSelect(int id)
        {
            AdminWithSelect result    = new AdminWithSelect();
            AdminsService   AdminServ = new AdminsService();
            var             model     = AdminServ.Reposity.FirstOrDefault(id);

            if (model == null)
            {
                model = new Admins();
            }
            result.Admin = model;
            List <int> tenantIds = new List <int>();

            if (model.ControlTenants != null)
            {
                foreach (var item in model.ControlTenants.Split(','))
                {
                    tenantIds.Add(int.Parse(item));
                }
            }

            List <int> powers = new List <int>();

            if (model.Powers != null)
            {
                foreach (var item in model.Powers.Split(','))
                {
                    powers.Add(int.Parse(item));
                }
            }

            TenantsService      TenServ    = new TenantsService();
            var                 tenants    = TenServ.Reposity.GetAllList();
            List <TenantSelect> TenantList = new List <TenantSelect>();

            foreach (var item in tenants)
            {
                TenantSelect obj = new TenantSelect();
                obj.Id         = item.Id;
                obj.selected   = tenantIds.Contains(item.Id);
                obj.TenantName = item.TenantName;
                TenantList.Add(obj);
            }
            result.Tenants = TenantList;

            CategoriesService CateServ = new CategoriesService();
            var Powers = CateServ.Reposity.GetAllList(o => o.Layout == "Powers");
            List <CategorySelect> PowerList = new List <CategorySelect>();

            foreach (var item in Powers)
            {
                CategorySelect obj = new CategorySelect();
                obj.Id           = item.Id;
                obj.selected     = powers.Contains(item.Id);
                obj.CategoryName = item.CategoryName;
                PowerList.Add(obj);
            }
            result.Powers = PowerList;

            AdminServ.Dispose();
            TenServ.Dispose();
            CateServ.Dispose();
            return(Json(result));
        }