public ActionResult Create()
        {
            var model = new ContentLabelModel();

            PrepareContentLabelModel(model);
            model.DisplayOrder = 999;
            return(View(model));
        }
        protected virtual void PrepareContentLabelModel(ContentLabelModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var allCategories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true);

            foreach (var c in allCategories)
            {
                c.Selected = model.SelectedCategoryIds.Contains(int.Parse(c.Value));
                model.AvailableCategories.Add(c);
            }
        }
        public ActionResult Create(ContentLabelModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var entity = model.MapTo <ContentLabel>();

                var labelId = _labelService.InsertContentLabel(entity);

                if (continueEditing)
                {
                    return(RedirectToAction("Edit", new { id = labelId }));
                }
                return(RedirectToAction("Index"));
            }

            PrepareContentLabelModel(model);
            return(View());
        }
        public ActionResult Edit(ContentLabelModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var entity = _labelService.GetContentLabelById(model.Id);
                entity = model.MapTo <ContentLabelModel, ContentLabel>(entity);
                _labelService.UpdateContentLabel(entity);

                if (continueEditing)
                {
                    return(RedirectToAction("Edit", new { id = model.Id }));
                }
                return(RedirectToAction("Index"));
            }

            PrepareContentLabelModel(model);
            return(View(model));
        }