public JsonResult RelationshipCategoryUpdate(string action)
        {
            List <RelationshipCategory> relationshipCategoryUpdateList = new List <RelationshipCategory>();
            var relationshipCategoryList = this.RelationshipCategoryService.GetRelationshipCategories().Select(m => m.RelationshipCategoryId).ToList();
            int recordCount = relationshipCategoryList.Count;
            int recordIndex = 0;

            if (action == "create")
            {
                string relationshipCategoryDescription = Request.Form["data[0][RelationshipCategory1]"].ToString();
                bool   hidden = bool.Parse(Request.Form["data[0][Hidden]"].ToString());

                RelationshipCategory relationshipCategoryNew = new RelationshipCategory()
                {
                    RelationshipCategory1 = relationshipCategoryDescription,
                    Hidden = hidden
                };
                relationshipCategoryUpdateList.Add(relationshipCategoryNew);
                this.RelationshipCategoryService.InsertRelationshipCategory(relationshipCategoryUpdateList[0]);
            }
            else
            {
                do
                {
                    if (Request.Form[string.Format("data[{0}][RelationshipCategory1]", relationshipCategoryList[recordIndex])] != null)
                    {
                        int    relationshipCategoryId          = relationshipCategoryList[recordIndex];
                        string RelationshipCategoryDescription = Request.Form[string.Format("data[{0}][RelationshipCategory1]", relationshipCategoryList[recordIndex])].ToString();
                        bool   hidden = bool.Parse(Request.Form[string.Format("data[{0}][Hidden]", relationshipCategoryList[recordIndex])].ToString());
                        RelationshipCategory relationshipCategoryNew = new RelationshipCategory()
                        {
                            RelationshipCategoryId = relationshipCategoryId,
                            RelationshipCategory1  = RelationshipCategoryDescription,
                            Hidden = hidden
                        };
                        relationshipCategoryUpdateList.Add(relationshipCategoryNew);
                    }
                    recordIndex++;
                }while (recordIndex < recordCount);

                for (int i = 0; i < relationshipCategoryUpdateList.Count; i++)
                {
                    switch (action)
                    {
                    case "edit":
                        this.RelationshipCategoryService.UpdateRelationshipCategory(relationshipCategoryUpdateList[i]);
                        break;

                    case "remove":
                        this.RelationshipCategoryService.DeleteRelationshipCategory(relationshipCategoryUpdateList[i].RelationshipCategoryId);
                        break;
                    }
                }
            }
            return(Json(new { data = relationshipCategoryUpdateList }, JsonRequestBehavior.AllowGet));
        }
 public RelationshipCategory UpdateRelationshipCategory(RelationshipCategory relationshipCategory)
 {
     return(this.relationshipCategoryRepository.UpdateRelationshipCategory(relationshipCategory));
 }
 public RelationshipCategory InsertRelationshipCategory(RelationshipCategory relationshipCategory)
 {
     return(this.relationshipCategoryRepository.InsertRelationshipCategory(relationshipCategory));
 }