示例#1
0
        public IEnumerable <SelectListItem> GetCategories()
        {
            var categories = _categoryLogic.GetAll().ToList().
                             Select(s => new SelectListItem
            {
                Text  = s.Name,
                Value = s.Id.ToString()
            }).ToList();

            return(categories);
        }
示例#2
0
		public IActionResult Index()
		{
			var categories = _categoryLogic.GetAll();
			var products = _productLogic.GetAll();

			var model = new ShopViewModel
			{
				Categories = categories,
				Products = products
			};

			return View(model);
		}
示例#3
0
        public CategoryModule(ICategoryLogic categoryLogic) : base("/category")
        {
            this._categoryLogic = categoryLogic;

            Get["/getallcategory"] = _ => //GetAllCategories();
            {
                try
                {
                    var json = new
                    {
                        Code = "0000",
                        Data = _categoryLogic.GetAll()
                    };

                    return(Response.AsText(JsonConvert.SerializeObject(json), "application/json;charset=UTF-8"));
                }
                catch (Exception ex)
                {
                    return(Response.AsText(JsonConvert.SerializeObject(new ResponseModel()
                    {
                        Code = "0009", Msg = ex.Message
                    }), "application/json;charset=UTF-8"));
                }
            };
        }
示例#4
0
        public IActionResult Index()
        {
            CategoryViewModel model = new CategoryViewModel
            {
                Categories = new List <CategoryModel>(),
                Tree       = _categoryLogic.GetCategoryTree()
            };

            var categories = _categoryLogic.GetAll();

            foreach (var category in categories)
            {
                model.Categories.Add(_mapper.GetCategoryModel(category));
            }

            return(View(model));
        }
示例#5
0
 public async Task <AdminPanel> GetPanel()
 {
     return(new AdminPanel
     {
         Projects = (await _projectLogic.GetAll()).ToList(),
         Comments = (await _commentLogic.GetAll()).ToList(),
         Categories = (await _categoryLogic.GetAll()).ToList()
     });
 }
 public IActionResult GetAll()
 {
     try
     {
         return(Ok(_categoryLogic.GetAll()));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
示例#7
0
        /// <summary>
        /// get all categories
        /// </summary>
        /// <returns></returns>
        private dynamic GetAllCategories()
        {
            var json = new
            {
                Code = "0000",
                Msg  = "success",
                Row  = _cateLogic.GetAll()
            };

            return(Response.AsText(JsonConvert.SerializeObject(json), "application/json; charset =UTF-8"));
        }
示例#8
0
        public List <SelectListItem> GetCategories()
        {
            var categories = _categoryLogic.GetAll().
                             Select(s => new SelectListItem
            {
                Text  = s.Name,
                Value = s.Id.ToString()
            }).ToList();

            categories.Add(new SelectListItem {
                Value = "0", Text = "Любая", Selected = true
            });

            return(categories);
        }
 public ActionResult getallcategory()
 {
     try
     {
         var list = _categoryLogic.GetAll();
         var json = new
         {
             Code = "0000",
             Data = list
         };
         return(Json(json, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new ResponseModel()
         {
             Code = "0009", Msg = ex.Message
         }));
     }
 }
示例#10
0
        /// <summary>
        /// get all categories
        /// </summary>
        /// <returns></returns>
        private dynamic GetAllCategories()
        {
            try
            {
                var json = new
                {
                    Code = "0000",
                    Data = _categoryLogic.GetAll()
                };

                return(Response.AsText(JsonConvert.SerializeObject(json), "application/json;charset=UTF-8"));
            }
            catch (Exception ex)
            {
                return(Response.AsText(JsonConvert.SerializeObject(new ResponseModel()
                {
                    Code = "0009", Msg = ex.Message
                }), "application/json;charset=UTF-8"));
            }
        }
示例#11
0
 public IActionResult GetAll()
 {
     return(Ok(CategoryLogic.GetAll().Select(x => new CategoryDetailedInfoModel(x)).ToList()));
 }
示例#12
0
 public ActionResult Index()
 {
     return(View(_categoryLogic.GetAll()));
 }
示例#13
0
 public IEnumerable <CategoryDto> Get()
 {
     return(_categoryLogic.GetAll());
 }