public JsonResult SaveItems(string ItemIds, string GroupId) { if (!string.IsNullOrEmpty(ItemIds)) { string[] arrayIds = ItemIds.Split(','); repo.Delete(Convert.ToInt32(GroupId)); UserGroupViewModel model = new UserGroupViewModel(); foreach (string item in arrayIds) { var id = item.ToString(); if (!string.IsNullOrEmpty(id)) { model.usergroupid = Convert.ToInt32(GroupId); model.menu_id = Convert.ToInt32(id); repo.Insert(model); } } return(Json("Access Saved Successfully")); } return(Json("Please Select Menu.")); }