예제 #1
0
        public ActionResult Create(int listId)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var list = listService.GetById(listId);

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", "List", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(list.Name);
            WorkContext.Breadcrumbs.Add(T("Categories"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new ListCategoryModel
            {
                ListId = listId
            };

            var result = new ControlFormResult <ListCategoryModel>(model)
            {
                Title                = T("Create Category").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var dataSource = listCategoryService.GetCategories(listId).Select(x => new { Key = x.Id.ToString(), Value = FormatCategoryText(x.Name, x.ParentId, listCategoryService.GetCategories(listId), "\xA0\xA0\xA0\xA0\xA0") }).ToList();

            dataSource.Insert(0, new { Key = "", Value = "" });
            result.RegisterExternalDataSource(x => x.ParentId, dataSource.ToDictionary(x => x.Key, x => x.Value));

            return(result);
        }
예제 #2
0
        public static CategoryModel[] GetCategories()
        {
            const string endpoint = "categories/";
            var          client   = new RestClient(URL);
            var          request  = new RestRequest(endpoint, Method.GET);

            CategoryModel[] result = null;

            try
            {
                IRestResponse response = client.Execute(request);
                if (response.StatusCode == HttpStatusCode.Created)
                {
                    result = ListCategoryModel.FromJson(response.Content);

                    // success = true;
                }
                else
                {
                    // NOK
                    Console.Write(response.ToString());
                }
            }
            catch (Exception error)
            {
                Console.Write(error.ToString());
            }

            return(result);
        }
예제 #3
0
        public ActionResult Index(ListCategoryModel model)
        {
            Title = "Quản trị danh mục trợ giúp ";
            ViewData["ToolbarTitle"] = Title;
            var listSieuWebCategories = _categoryService.GetAllCategory();

            foreach (var item in listSieuWebCategories)
            {
                var sieuWebCategoryModel = item.ToModel();
                model.ListCategories.Add(sieuWebCategoryModel);
            }
            return(View(model));
        }
예제 #4
0
        public ActionResult Update(ListCategoryModel model)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            ListCategory item;

            if (model.ParentId.HasValue && model.ParentId.Value != 0)
            {
                item = listCategoryService.GetById(model.ParentId.Value);
            }
            else
            {
                item = null;
            }

            var category = model.Id != 0
                ? listCategoryService.GetById(model.Id)
                : new ListCategory();

            category.Name = model.Name;
            category.Url  = model.Url;

            if (string.IsNullOrEmpty(category.Url))
            {
                category.Url = category.Name.ToSlugUrl();
            }

            if (item != null)
            {
                category.FullUrl = item.FullUrl + "/" + category.Url;
            }
            else
            {
                category.FullUrl = category.Url;
            }

            category.ParentId = model.ParentId;
            category.ListId   = model.ListId;
            listCategoryService.Save(category);

            return(new AjaxResult().NotifyMessage("UPDATE_ENTITY_COMPLETE").CloseModalDialog());
        }
예제 #5
0
        public ActionResult Index(CategoryCondition Condition)
        {
            int errorId = CheckRole(_roles);

            if (errorId < 0)
            {
                return(Redirect(errorId));
            }
            ListCategoryModel model = new ListCategoryModel();

            model.ListCategory = _service.List(Condition.SearchText);
            if (model.ListCategory.Count == 0)
            {
                model.ListCategory = new List <Entities.Category>();
            }
            model.Condition = Condition;

            return(View(model));
        }