public JsonNetResult CreateCategory(List <TranslatedCategory> transdesc, Guid?parentID) { try { //2015-09-08 //Ivan S. //66 //Sets the initial order for the new category to the maximum number for all the categories var lastCategory = Exigo.GetResourceCategories(new GetResourceCategoriesRequest()).OrderByDescending(rc => rc.CategoryOrder).FirstOrDefault(); int?lastCategoryOrder = InitialOrderValue - 1; if (lastCategory != null) { lastCategoryOrder = lastCategory.CategoryOrder; } var NewOrder = ++lastCategoryOrder; var CategoryID = Guid.NewGuid(); if (parentID == null) { parentID = Guid.Empty; } foreach (var description in transdesc) { //English is the Default Language and will be used as the Description on the Categories Table if (description.Language == "English") { ResourceCategory Category = new ResourceCategory() { CategoryID = CategoryID, CategoryDescription = description.TranslatedCategoryDescription, CategoryOrder = NewOrder, ParentID = (Guid)parentID }; Exigo.AddResourceCategory(Category); } //Adds an entry for each language translation provided in the TranslatedCategoryItems table ResourceTranslatedCategoryItem TCategory = new ResourceTranslatedCategoryItem() { TranslatedCategoryID = Guid.NewGuid(), CategoryID = CategoryID, Language = description.Language, TranslatedCategoryDescription = description.TranslatedCategoryDescription }; Exigo.AddCategoryTranslation(TCategory); } return(new JsonNetResult(new { success = true })); } catch (Exception ex) { return(new JsonNetResult(new { success = false, message = ex.Message })); } }
public JsonNetResult EditCategory(List <TranslatedCategory> items, Guid categoryID, Guid?parentID) { try { foreach (var item in items.Where(i => !i.Language.IsNullOrEmpty())) { if (item.Language == "English") { //Update the Resource var resourceCategory = Exigo.GetResourceCategories(new GetResourceCategoriesRequest() { CategoryID = categoryID }).FirstOrDefault(); resourceCategory.CategoryDescription = item.TranslatedCategoryDescription; resourceCategory.ParentID = parentID ?? Guid.Empty; Exigo.ModifyResourceCategory(resourceCategory); } //Update the Translations var translatedCategory = Exigo.GetCategoryTranslations(new GetTranslatedCategoryRequest() { Language = item.Language, CategoryID = categoryID }).FirstOrDefault(); if (translatedCategory != null) { translatedCategory.TranslatedCategoryDescription = item.TranslatedCategoryDescription; Exigo.ModifyResourceTranslationDescription(translatedCategory); } else { ResourceTranslatedCategoryItem TCategory = new ResourceTranslatedCategoryItem() { TranslatedCategoryID = Guid.NewGuid(), CategoryID = categoryID, Language = item.Language, TranslatedCategoryDescription = item.TranslatedCategoryDescription }; Exigo.AddCategoryTranslation(TCategory); } } return(new JsonNetResult(new { success = true })); } catch (Exception ex) { return(new JsonNetResult(new { success = false, message = ex.Message })); } }