예제 #1
0
        public static dynamic RemoverPermissao(PermissaoViewModel viewModel)
        {
            try
            {
                //#region Connection
                //Connection connection = Connection.Instance;
                //connection.ConnectionString = VisualWebPart1._connectionString;
                //connection.User = VisualWebPart1._username;
                //connection.Password = VisualWebPart1._password;
                //#endregion

                IApplicationFacade application = new ApplicationFacade();

                application.RemoverPermissaoSite(viewModel.site, viewModel.nome);
                //var list = new List<Site>();

                //SPSecurity.RunWithElevatedPrivileges(delegate()
                //{
                //    using (SPWeb web = new SPSite(SPContext.Current.Site.ID).OpenWeb(String.Concat(@"/", viewModel.site)))
                //    {
                //        var anterior = web.AllowUnsafeUpdates;
                //        web.AllowUnsafeUpdates = true;

                //        try
                //        {
                //            web.RoleAssignments.Remove(web.SiteGroups[viewModel.nome]);
                //        }
                //        catch (Exception)
                //        {
                //            web.RoleAssignments.Remove(web.EnsureUser(viewModel.nome));
                //        }

                //        web.Update();
                //        web.AllowUnsafeUpdates = !anterior;
                //    }
                //});


                return(JsonConvert.SerializeObject(
                           viewModel, new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }