public ActionResult Role(Role model)
        {
            Guid            recordId = Guid.Empty;
            GenelRepository gnlDB    = RepositoryManager.GetRepository <GenelRepository>();

            SessionContext.Current.ActiveUser.MenuId = model.MenuId;
            ViewBag.Success = true;


            ModelState.Remove("is_active");

            if (model.FromDeleteButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    gnlDB.DeleteRole(model, Guid.Parse(model.RecordId));
                    return(RedirectToAction("ListPage", "General", new { MenuId = Dcm.Source.GlobalHelper.Encrypt(model.MenuId) }));
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (GlobalHelper.IsGuid(model.RecordId))
                    {
                        recordId = Guid.Parse(model.RecordId);
                        try
                        {
                            model = gnlDB.UpdateRole(model, recordId);
                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            gnl_roles role = new gnl_roles();
                            gnlDB.AddRole(role, model);
                            model.RecordId        = role.role_id.ToString();
                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                }
                else
                {
                    ViewBag.Success = false;
                }

                Guid role_uid = Guid.Empty;
                if (Guid.TryParse(model.RecordId, out role_uid))
                {
                    List <gnl_role_related_users_v> listRoleRelatedUsers = gnlDB.GetRoleRelatedUsers(role_uid);
                    model.roleRelatedUsers = listRoleRelatedUsers;
                }
            }

            return(View(model));
        }