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 = ExigoDAL.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 }; ExigoDAL.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 }; ExigoDAL.AddCategoryTranslation(TCategory); } return(new JsonNetResult(new { success = true })); } catch (Exception ex) { return(new JsonNetResult(new { success = false, message = ex.Message })); } }