public ActionResult RoleAuthorization(RoleAuthorization model, FormCollection formCollection)
        {
            GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>();

            model.activeRoles = gnlDB.GetActiveRoles();
            ViewBag.Success   = true;

            SessionContext.Current.ActiveUser.FromUpdateButton = model.FromUpdateButton;
            SessionContext.Current.ActiveUser.SelectedRoleId   = model.SelectedRoleId;

            if (SessionContext.Current.ActiveUser.FromUpdateButton == "1")
            {
                try
                {
                    gnlDB.DeleteRoleRights(model.SelectedRoleId);

                    DataSet dsMenu = BaseDB.DBManager.AppConnection.GetDataSet("select * from gnl_menu");

                    foreach (DataRow row in dsMenu.Tables[0].Rows)
                    {
                        bool menuRight      = false;
                        bool deleteRight    = false;
                        bool updateRight    = false;
                        bool reportRight    = false;
                        bool newRecordRight = false;

                        foreach (var key in formCollection.AllKeys)
                        {
                            string[] arr = key.Split('_');
                            if (arr.Length > 1)
                            {
                                if (arr[1] != "" && BaseFunctions.getInstance().IsNumeric(arr[1]) && arr[1] == row["menu_id"].ToString())
                                {
                                    if (arr[0] == "Show")
                                    {
                                        menuRight = true;
                                    }

                                    if (arr[0] == "Update")
                                    {
                                        updateRight = true;
                                    }

                                    if (arr[0] == "Delete")
                                    {
                                        deleteRight = true;
                                    }

                                    if (arr[0] == "Report")
                                    {
                                        reportRight = true;
                                    }

                                    if (arr[0] == "NewRecord")
                                    {
                                        newRecordRight = true;
                                    }
                                }
                            }
                        }
                        gnl_role_rights rights = new gnl_role_rights();
                        gnlDB.AddRoleRights(rights, Guid.Parse(model.SelectedRoleId), Convert.ToInt32(row["menu_id"].ToString()), menuRight, updateRight, deleteRight, reportRight, newRecordRight);
                    }

                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
                catch (Exception exp)
                {
                    ViewBag.Success = false;
                    ModelState.AddModelError("Error", exp.Message);
                }
            }
            return(View(model));
        }