Exemplo n.º 1
0
        public void EnableOrDisabled(ProfileForScreen entity, long userId)
        {
            _context.ProfileForScreen.AddOrUpdate(entity);
            _context.SaveChanges();

            //_logRepository.Add(new Log().GeneratedForEntity(userId, entity, entity.Id != 0 ? LogTypeResource.Update : LogTypeResource.Insert));
        }
        public void EnableOrDisabled(int profileId, int screenId, string parametro, long permissionId, long userId)
        {
            ProfileForScreen permission;

            if (permissionId != 0)
            {
                permission = _permissionRepository.GetProfileForScreen(permissionId);
            }
            else
            {
                permission = new ProfileForScreen
                {
                    ProfileId = profileId,
                    ScreenId  = screenId,
                };
            }

            if (parametro.Equals("Read"))
            {
                permission.Read = !permission.Read;
            }
            else if (parametro.Equals("Create"))
            {
                permission.Create = !permission.Create;
            }
            else if (parametro.Equals("Update"))
            {
                permission.Update = !permission.Update;
            }
            else if (parametro.Equals("Delete"))
            {
                permission.Delete = !permission.Delete;
            }
            else
            {
                return;
            }

            _permissionRepository.EnableOrDisabled(permission, userId);
        }
        public void EnableOrDisabled(int profileId, int screenId, bool ativar, long permissionId, long userId)
        {
            ProfileForScreen permission;

            if (permissionId != 0)
            {
                permission = _permissionRepository.GetProfileForScreen(permissionId);
            }
            else
            {
                permission = new ProfileForScreen
                {
                    ProfileId = profileId,
                    ScreenId  = screenId,
                };
            }

            var screen = _permissionRepository.GetScreen(screenId);

            if (screen.Read)
            {
                permission.Read = ativar;
            }
            if (screen.Create)
            {
                permission.Create = ativar;
            }
            if (screen.Update)
            {
                permission.Update = ativar;
            }
            if (screen.Delete)
            {
                permission.Delete = ativar;
            }

            _permissionRepository.EnableOrDisabled(permission, userId);
        }