public SiteUrl Permalink(CategoryDto item) { string[] segments = item == null ? null : new[] { item.Slug.ToString(CultureInfo.InvariantCulture) }; return new SiteUrl(this.Domain, this.HttpPort, false, null, "Category", "Archive", segments, null); }
public SiteUrl Edit(CategoryDto item) { string[] segments = item == null ? null : new[] { item.Id.ToString(CultureInfo.InvariantCulture) }; return new SiteUrl(this.Domain, this.HttpPort, false, "Dxt-Admin", "Category", "Manage", segments, null); }
public string WpNewCategory(string blog_id, string username, string password, WpNewCategory category) { this.ValidateUser(username, password); IList<CategoryDto> categories = this.categoryService.GetCategories(); CategoryDto cat = categories.FirstOrDefault(x => x.Name.ToLowerInvariant() == category.name.ToLowerInvariant()); CategoryDto parentCategory = null; if (category.parent_id > 0) { parentCategory = categories.FirstOrDefault(c => c.Parent.Id == category.parent_id); } if (cat == null) { cat = new CategoryDto { Name = category.name, Parent = parentCategory }; this.categoryService.SaveOrUpdate(cat); } else { if (cat.Parent != null && cat.Parent.Id != parentCategory.Id) { cat.Parent.Id = parentCategory.Id; this.categoryService.SaveOrUpdate(cat); } } return cat.Id.ToString(CultureInfo.InvariantCulture); }
public ActionResult Manage(int? id, CategoryBinder category) { if (!this.ModelState.IsValid) { ManageViewModel model = new ManageViewModel(); model.Category = category; model.Categories = id.HasValue ? this.categoryService.GetCategories().Where(x => x.Id != id.Value) : this.categoryService.GetCategories(); return this.View(model); } try { CategoryDto newCategory; if (id.HasValue && id.Value > 0) { newCategory = this.categoryService.GetCategoryById(id.Value); } else { newCategory = new CategoryDto(); } if (category.ParentId.HasValue) { newCategory.Parent = this.categoryService.GetCategoryById(category.ParentId.Value); } if (!string.IsNullOrEmpty(category.FeedBurnerUrl)) { newCategory.FeedBurnerUrl = new Uri(category.FeedBurnerUrl); } newCategory.Name = category.Name; newCategory.Description = category.Description; newCategory.IsDefault = category.IsDefault; this.categoryService.SaveOrUpdate(newCategory); return this.urlBuilder.Admin.FeedbackPage(FeedbackType.Positive, "Category Saved", this.urlBuilder.Admin.Category.List()).Redirect(); } catch (DexterException e) { this.Logger.ErrorFormat("Unable to save the specified category", e); return this.urlBuilder.Admin.FeedbackPage(FeedbackType.Negative, "Category Not Saved", this.urlBuilder.Admin.Category.List()).Redirect(); } }
public static Task SaveOrUpdateAsync(this ICategoryService categoryService, CategoryDto category) { return Task.Factory.StartNewDexterTask(() => categoryService.SaveOrUpdate(category)); }
public string SaveOrUpdate(CategoryDto item) { if (item == null) { throw new ArgumentNullException("item", "Category item cannot be null."); } if (item.Name == null) { throw new ArgumentNullException("item.Name", "Category name cannot be null."); } if (item.Name == string.Empty) { throw new ArgumentException("Category name cannot be empty", "item.Name"); } Category category; string oldCategoryName = null; if (item.Id > 0) { category = this.Session.Load<Category>(item.Id); oldCategoryName = category.Name; if (category == null) { throw new DexterCategoryNotFoundException(item.Id); } } else { category = new Category(); } item.MapPropertiesToInstance(category); category.ParentId = category.ParentId; if (string.IsNullOrEmpty(category.Slug)) { category.Slug = SlugHelper.GenerateSlug(category.Name, category.Id, this.GetCategoryBySlug); } this.Session.Store(category); UpdateCategoryIndex.UpdateCategoryIndexes(this.store, this.Session, category, oldCategoryName); return category.Id; }
public void SaveOrUpdate(CategoryDto category) { this.categoryDataService.SaveOrUpdate(category); }