public void MapToPermissionRepo(Models.Permission permission)
 {
     this.Permission = new PermissionRepository()
     {
         Name = permission.Name,
         Id   = permission.Id
     };
 }
Exemplo n.º 2
0
 private void save(Models.Permission Permission, bool isUpdate = false)
 {
     if (!isUpdate)
     {
         this.context.Permissions.Add(Permission);
     }
     this.context.SaveChanges();
 }
Exemplo n.º 3
0
        public void Update(long id, PermissionRepository permissionRepository)
        {
            Models.Permission oldPermission = this.permissionQueryRepository.Find(id);
            if (oldPermission == null)
            {
                return;
            }

            oldPermission.Name = permissionRepository.Name;
            this.save(oldPermission, true);
        }
        public PermissionRepository FindByName(string name)
        {
            Models.Permission permission = this.context.Permissions.Where(permission => permission.Name == name).FirstOrDefault();
            if (permission == null)
            {
                return(new PermissionRepository());
            }

            this.permissionRepository.Id   = permission.Id;
            this.permissionRepository.Name = permission.Name;

            return(this.permissionRepository);
        }
        public PermissionRepository FindById(long id = 0)
        {
            Models.Permission permission = this.Find(id);
            if (permission == null)
            {
                return(new PermissionRepository());
            }

            this.permissionRepository.Id   = permission.Id;
            this.permissionRepository.Name = permission.Name;

            return(this.permissionRepository);
        }
Exemplo n.º 6
0
 public void Delete(long id)
 {
     Models.Permission permission = this.context.Permissions.Where(permission => permission.Id == id).FirstOrDefault();
     this.context.Permissions.Remove(permission);
     this.context.SaveChanges();
 }
Exemplo n.º 7
0
 public void Create(PermissionRepository permissionRepository)
 {
     Models.Permission newPermission = new Models.Permission();
     newPermission.Name = permissionRepository.Name;
     this.save(newPermission);
 }